Spaces replaced with tabs

main
Inga 🏳‍🌈 14 years ago
parent c2db737fa3
commit 235c97a589
  1. 20
      IISMainHandler/Extensions.cs
  2. 16
      IISMainHandler/HandlersFactory.cs
  3. 6
      IISMainHandler/ISpecificHandler.cs
  4. 20
      IISMainHandler/MainHandler.cs
  5. 10
      IISMainHandler/TemplateEngine.cs
  6. 64
      IISMainHandler/WebContext.cs
  7. 4
      IISMainHandler/designs/Classic.cs
  8. 4
      IISMainHandler/designs/IDesign.cs
  9. 4
      IISMainHandler/designs/Lite.cs
  10. 20
      IISMainHandler/handlers/AbstractGetHandler.cs
  11. 24
      IISMainHandler/handlers/DebugHandler.cs
  12. 20
      IISMainHandler/handlers/RootHandler.cs
  13. 10
      IISMainHandler/handlers/WrongUrlHandler.cs

@ -5,17 +5,17 @@ using System.Text;
using System.Web; using System.Web;
namespace FLocal.IISHandler { namespace FLocal.IISHandler {
static class Extensions { static class Extensions {
public static void WriteLine(this HttpResponse response, string toWrite) { public static void WriteLine(this HttpResponse response, string toWrite) {
response.Write(toWrite); response.Write(toWrite);
response.Write((char)0x0d); response.Write((char)0x0d);
response.Write((char)0x0a); response.Write((char)0x0a);
} }
public static string[] Split(this string str, string separator, StringSplitOptions options) { public static string[] Split(this string str, string separator, StringSplitOptions options) {
return str.Split(new string[] { separator }, options); return str.Split(new string[] { separator }, options);
} }
} }
} }

@ -5,14 +5,14 @@ using System.Text;
using System.Web; using System.Web;
namespace FLocal.IISHandler { namespace FLocal.IISHandler {
class HandlersFactory { class HandlersFactory {
public static ISpecificHandler getHandler(WebContext context) { public static ISpecificHandler getHandler(WebContext context) {
string[] requestParts = context.httprequest.Path.Split("/", StringSplitOptions.RemoveEmptyEntries); string[] requestParts = context.httprequest.Path.Split("/", StringSplitOptions.RemoveEmptyEntries);
if(requestParts.Length < 1) return new handlers.RootHandler(); if(requestParts.Length < 1) return new handlers.RootHandler();
return new handlers.DebugHandler(requestParts[0]); return new handlers.DebugHandler(requestParts[0]);
//return new handlers.WrongUrlHandler(); //return new handlers.WrongUrlHandler();
} }
} }
} }

@ -5,9 +5,9 @@ using System.Text;
using System.Web; using System.Web;
namespace FLocal.IISHandler { namespace FLocal.IISHandler {
interface ISpecificHandler { interface ISpecificHandler {
void Handle(WebContext context); void Handle(WebContext context);
} }
} }

@ -5,17 +5,17 @@ using System.Text;
using System.Web; using System.Web;
namespace FLocal.IISHandler { namespace FLocal.IISHandler {
public class MainHandler : IHttpHandler { public class MainHandler : IHttpHandler {
public bool IsReusable { public bool IsReusable {
get { return true; } get { return true; }
} }
public void ProcessRequest(HttpContext httpcontext) { public void ProcessRequest(HttpContext httpcontext) {
WebContext context = new WebContext(httpcontext); WebContext context = new WebContext(httpcontext);
ISpecificHandler handler = HandlersFactory.getHandler(context); ISpecificHandler handler = HandlersFactory.getHandler(context);
handler.Handle(context); handler.Handle(context);
} }
} }
} }

@ -5,11 +5,11 @@ using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace FLocal.IISHandler { namespace FLocal.IISHandler {
class TemplateEngine { class TemplateEngine {
public static string Compile(string pathToTemplate, XDocument data) { public static string Compile(string pathToTemplate, XDocument data) {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
} }

@ -5,36 +5,36 @@ using System.Text;
using System.Web; using System.Web;
namespace FLocal.IISHandler { namespace FLocal.IISHandler {
class WebContext { class WebContext {
public readonly HttpContext httpcontext; public readonly HttpContext httpcontext;
public HttpRequest httprequest { public HttpRequest httprequest {
get { get {
return this.httpcontext.Request; return this.httpcontext.Request;
} }
} }
public HttpResponse httpresponse { public HttpResponse httpresponse {
get { get {
return this.httpcontext.Response; return this.httpcontext.Response;
} }
} }
public designs.IDesign design { public designs.IDesign design {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public WebContext(HttpContext httpcontext) { public WebContext(HttpContext httpcontext) {
this.httpcontext = httpcontext; this.httpcontext = httpcontext;
} }
public string Transform(string templateName, System.Xml.Linq.XDocument data) { public string Transform(string templateName, System.Xml.Linq.XDocument data) {
//TODO: this should work according to design! //TODO: this should work according to design!
return TemplateEngine.Compile(templateName, data); return TemplateEngine.Compile(templateName, data);
} }
} }
} }

@ -4,6 +4,6 @@ using System.Linq;
using System.Text; using System.Text;
namespace FLocal.IISHandler.designs { namespace FLocal.IISHandler.designs {
class Classic : IDesign { class Classic : IDesign {
} }
} }

@ -4,6 +4,6 @@ using System.Linq;
using System.Text; using System.Text;
namespace FLocal.IISHandler.designs { namespace FLocal.IISHandler.designs {
interface IDesign { interface IDesign {
} }
} }

@ -4,6 +4,6 @@ using System.Linq;
using System.Text; using System.Text;
namespace FLocal.IISHandler.designs { namespace FLocal.IISHandler.designs {
class Lite : IDesign { class Lite : IDesign {
} }
} }

@ -4,17 +4,17 @@ using System.Linq;
using System.Text; using System.Text;
namespace FLocal.IISHandler.handlers { namespace FLocal.IISHandler.handlers {
abstract class AbstractGetHandler : ISpecificHandler { abstract class AbstractGetHandler : ISpecificHandler {
abstract protected string templateName { abstract protected string templateName {
get; get;
} }
abstract protected System.Xml.Linq.XDocument getData(WebContext context); abstract protected System.Xml.Linq.XDocument getData(WebContext context);
public void Handle(WebContext context) { public void Handle(WebContext context) {
context.httpresponse.Write(context.Transform(this.templateName, this.getData(context))); context.httpresponse.Write(context.Transform(this.templateName, this.getData(context)));
} }
} }
} }

@ -5,20 +5,20 @@ using System.Text;
using System.Web; using System.Web;
namespace FLocal.IISHandler.handlers { namespace FLocal.IISHandler.handlers {
class DebugHandler : ISpecificHandler { class DebugHandler : ISpecificHandler {
private string type; private string type;
public DebugHandler(string type) { public DebugHandler(string type) {
this.type = type; this.type = type;
} }
public void Handle(WebContext context) { public void Handle(WebContext context) {
context.httpresponse.ContentType = "text/plain"; context.httpresponse.ContentType = "text/plain";
context.httpresponse.WriteLine("Page: " + this.type); context.httpresponse.WriteLine("Page: " + this.type);
context.httpresponse.WriteLine("Path: " + context.httprequest.Path); context.httpresponse.WriteLine("Path: " + context.httprequest.Path);
context.httpresponse.WriteLine("PathInfo: " + context.httprequest.PathInfo); context.httpresponse.WriteLine("PathInfo: " + context.httprequest.PathInfo);
} }
} }
} }

@ -7,18 +7,18 @@ using System.Xml.Linq;
namespace FLocal.IISHandler.handlers { namespace FLocal.IISHandler.handlers {
class RootHandler : AbstractGetHandler { class RootHandler : AbstractGetHandler {
override protected string templateName { override protected string templateName {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
override protected XDocument getData(WebContext context) { override protected XDocument getData(WebContext context) {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
} }

@ -5,11 +5,11 @@ using System.Text;
using System.Web; using System.Web;
namespace FLocal.IISHandler.handlers { namespace FLocal.IISHandler.handlers {
class WrongUrlHandler : ISpecificHandler { class WrongUrlHandler : ISpecificHandler {
public void Handle(WebContext context) { public void Handle(WebContext context) {
throw new HttpException(404, "page not found"); throw new HttpException(404, "page not found");
} }
} }
} }

Loading…
Cancel
Save