CôaCôaCôa

Un peu de tout et n'importe quoi...

Plagiat

I ran across Russell-Beattie-Notebook's dreams on Java (boils down to "I don't know jack about Python, but the indentation thing is cool!") and I thought about C# doing the same exact thing. Change nothing else but make indentation count. Suddenly C# looks really clean!

Here's a C# code with indentation:

using System
using System.Web
using System.Collections
using System.ComponentModel
using System.Web.SessionState
using Dottext.Framework.Components
using Dottext.Framework
using Dottext.Framework.Util
using Dottext.Framework.Configuration

namespace Dottext.Web.Modules

  /// <summary>
  /// Summary description for BlogServiceModule.
  /// </summary>
  public class BlogServiceModule : IHttpModule

    public BlogServiceModule()
      // TODO: Add constructor logic here

    void IHttpModule.Init(HttpApplication context) 
      context.BeginRequest += new EventHandler(this.ReWriteServicePath)
          
    void ReWriteServicePath(object sender, EventArgs e)
      HttpContext context  = ((HttpApplication)sender).Context
      string path = context.Request.Path.ToLower()
      if(path.IndexOf("services") > 0 && path.IndexOf(".asmx") > 0)
        if(AlllowService(context))
          string fileName = System.IO.Path.GetFileName(context.Request.Path)
          context.RewritePath("~/Services/" + fileName)
        else
          context.Response.Clear()
          context.Response.End()

    private bool AlllowService(HttpContext context)
      return  ( 
            Config.Settings.AllowServiceAccess &&
            (context.Request.RequestType == "GET" || Config.CurrentBlog(context).AllowServiceAccess)
          )

    void IHttpModule.Dispose()

Damn, that looks pretty clean! Notice I didn't get rid of *all* semi-colons, just the ones at the end of statements and it's pretty cool. I actually grabbed a much bigger class file that I have and formatted it, then got rid of the {}'s and ;'s and it too was very clean.

Not that this would ever happen, but it'd be cool.

-Michel

Comments

Jim Arnold said:

Well I think it looks horrible :-)

Jim
# March 26, 2004 9:33 AM

CC said:


Eyeuw..... if I wanted to use COBOL ... ;)
# March 26, 2004 9:58 AM

senkwe said:

Looks terrible to me I'm afraid :-)
# March 26, 2004 1:24 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)