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;
namespace FLocal.IISHandler {
static class Extensions {
static class Extensions {
public static void WriteLine(this HttpResponse response, string toWrite) {
response.Write(toWrite);
response.Write((char)0x0d);
response.Write((char)0x0a);
}
public static void WriteLine(this HttpResponse response, string toWrite) {
response.Write(toWrite);
response.Write((char)0x0d);
response.Write((char)0x0a);
}
public static string[] Split(this string str, string separator, StringSplitOptions options) {
return str.Split(new string[] { separator }, options);
}
public static string[] Split(this string str, string separator, StringSplitOptions options) {
return str.Split(new string[] { separator }, options);
}
}
}
}

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save