├── UpgradeLog.XML
├── UpgradeLog.htm
├── ALE.ConsoleTest
├── Views
│ └── ViewTest.cshtml
├── TestController.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── ALE.ConsoleTest.csproj
├── AleIISTest
├── Global.asax
├── Web.config
├── Web.Debug.config
├── Web.Release.config
├── Properties
│ └── AssemblyInfo.cs
├── Global.asax.cs
└── AleIISTest.csproj
├── ALE.Http
├── PreProcessor.cs
├── PostProcessor.cs
├── IController.cs
├── Controller.cs
├── IContext.cs
├── IRequest.cs
├── Routing.cs
├── IResponse.cs
├── ListenerContext.cs
├── Properties
│ └── AssemblyInfo.cs
├── ListenerRequest.cs
├── ALE.Http.csproj
├── Route.cs
├── ListenerResponse.cs
├── Server.cs
└── Static.cs
├── Backup
├── AleIISTest
│ ├── Global.asax
│ ├── Web.config
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Global.asax.cs
│ └── AleIISTest.csproj
└── ALE.sln
├── _UpgradeReport_Files
├── UpgradeReport_Error.png
├── UpgradeReport_Success.png
├── UpgradeReport_Warning.png
├── UpgradeReport_Information.png
├── UpgradeReport.css
└── UpgradeReport.xslt
├── packages
├── RazorEngine.3.0.8
│ ├── RazorEngine.3.0.8.nupkg
│ └── lib
│ │ └── net40
│ │ ├── RazorEngine.dll
│ │ └── System.Web.Razor.dll
└── repositories.config
├── ALE.Views.Razor
├── packages.config
├── Properties
│ └── AssemblyInfo.cs
├── RazorView.cs
└── ALE.Views.Razor.csproj
├── ALE
├── Views
│ └── IViewProcessor.cs
├── Tcp
│ ├── Net.cs
│ ├── WebSocketServer.cs
│ ├── WebSocketHandshake.cs
│ └── WebSocket.cs
├── Deferrer.cs
├── FileSystem
│ ├── AsyncFileReadState.cs
│ ├── ReadAsyncCallbackState.cs
│ ├── FileSystemWatcher.cs
│ └── File.cs
├── EventLoopWorker.cs
├── Properties
│ └── AssemblyInfo.cs
├── Promise.cs
├── EventLoop.cs
├── ALE.csproj
└── Do.cs
├── .gitignore
├── Local.testsettings
├── ALE.vsmdi
├── ALE.Web
├── AleHttpHandler.cs
├── Server.cs
├── AleContext.cs
├── Properties
│ └── AssemblyInfo.cs
├── AleHttpHandlerAsync.cs
├── AleRequest.cs
├── ALE.Web.csproj
└── AleResponse.cs
├── ALE.Tests
├── Http
│ └── Routing_Tests.cs
├── Properties
│ └── AssemblyInfo.cs
├── Do_Tests.cs
├── Promise_Tests.cs
├── ALE.Tests.csproj
└── EventLoop_Tests.cs
├── license.txt
├── ALE.Sql
├── Properties
│ └── AssemblyInfo.cs
├── ALE.Sql.csproj
└── Sql.cs
├── TraceAndTestImpact.testsettings
├── README.md
└── ALE.sln
/UpgradeLog.XML:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/benlesh/ALE/HEAD/UpgradeLog.XML
--------------------------------------------------------------------------------
/UpgradeLog.htm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/benlesh/ALE/HEAD/UpgradeLog.htm
--------------------------------------------------------------------------------
/ALE.ConsoleTest/Views/ViewTest.cshtml:
--------------------------------------------------------------------------------
1 | @model ALE.ConsoleTest.TestModel
2 |
3 |
@Model.Title
--------------------------------------------------------------------------------
/AleIISTest/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="AleIISTest.Global" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/ALE.Http/PreProcessor.cs:
--------------------------------------------------------------------------------
1 | namespace ALE.Http
2 | {
3 | public delegate void PreProcessor(IRequest req, IResponse res);
4 | }
--------------------------------------------------------------------------------
/Backup/AleIISTest/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="AleIISTest.Global" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/ALE.Http/PostProcessor.cs:
--------------------------------------------------------------------------------
1 | namespace ALE.Http
2 | {
3 | public delegate void PostProcessor(IRequest req, IResponse res);
4 | }
--------------------------------------------------------------------------------
/_UpgradeReport_Files/UpgradeReport_Error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/benlesh/ALE/HEAD/_UpgradeReport_Files/UpgradeReport_Error.png
--------------------------------------------------------------------------------
/_UpgradeReport_Files/UpgradeReport_Success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/benlesh/ALE/HEAD/_UpgradeReport_Files/UpgradeReport_Success.png
--------------------------------------------------------------------------------
/_UpgradeReport_Files/UpgradeReport_Warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/benlesh/ALE/HEAD/_UpgradeReport_Files/UpgradeReport_Warning.png
--------------------------------------------------------------------------------
/_UpgradeReport_Files/UpgradeReport_Information.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/benlesh/ALE/HEAD/_UpgradeReport_Files/UpgradeReport_Information.png
--------------------------------------------------------------------------------
/packages/RazorEngine.3.0.8/RazorEngine.3.0.8.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/benlesh/ALE/HEAD/packages/RazorEngine.3.0.8/RazorEngine.3.0.8.nupkg
--------------------------------------------------------------------------------
/ALE.Views.Razor/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/RazorEngine.3.0.8/lib/net40/RazorEngine.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/benlesh/ALE/HEAD/packages/RazorEngine.3.0.8/lib/net40/RazorEngine.dll
--------------------------------------------------------------------------------
/packages/RazorEngine.3.0.8/lib/net40/System.Web.Razor.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/benlesh/ALE/HEAD/packages/RazorEngine.3.0.8/lib/net40/System.Web.Razor.dll
--------------------------------------------------------------------------------
/packages/repositories.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ALE/Views/IViewProcessor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace ALE.Views
3 | {
4 | public interface IViewProcessor
5 | {
6 | void Render(string view, object model, Action callback);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ALE.Http/IController.cs:
--------------------------------------------------------------------------------
1 | namespace ALE.Http
2 | {
3 | public interface IController
4 | {
5 | IRequest Request { get; set; }
6 |
7 | IResponse Response { get; set; }
8 |
9 | IContext Context { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/ALE/Tcp/Net.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 |
4 | namespace ALE.Tcp
5 | {
6 | public class Net
7 | {
8 | public static WebSocketServer CreateServer(Action callback)
9 | {
10 | return new WebSocketServer(callback);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/ALE.ConsoleTest/TestController.cs:
--------------------------------------------------------------------------------
1 | using ALE.Http;
2 |
3 | namespace ALE.ConsoleTest
4 | {
5 | public class TestController : Controller
6 | {
7 | public void Route1()
8 | {
9 | Response.Write("Route1 found!");
10 | }
11 |
12 | public void Route2(int foo)
13 | {
14 | Response.Write("Foo: " + foo);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | #ignore thumbnails created by windows
3 | Thumbs.db
4 | #Ignore files build by Visual Studio
5 | *.obj
6 | *.exe
7 | *.pdb
8 | *.user
9 | *.aps
10 | *.pch
11 | *.vspscc
12 | *_i.c
13 | *_p.c
14 | *.ncb
15 | *.suo
16 | *.tlb
17 | *.tlh
18 | *.bak
19 | *.cache
20 | *.ilk
21 | *.log
22 | [Bb]in
23 | [Dd]ebug*/
24 | *.lib
25 | *.sbr
26 | obj/
27 | [Rr]elease*/
28 | _ReSharper*/
29 | [Tt]est[Rr]esult*
30 |
--------------------------------------------------------------------------------
/ALE.Http/Controller.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ALE.Http
7 | {
8 | public abstract class Controller : IController
9 | {
10 | public IRequest Request { get; set; }
11 |
12 | public IResponse Response { get; set; }
13 |
14 | public IContext Context { get; set; }
15 |
16 | protected Controller()
17 | {
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Local.testsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | These are default test settings for a local test run.
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ALE/Deferrer.cs:
--------------------------------------------------------------------------------
1 | namespace ALE
2 | {
3 | public class Deferrer
4 | {
5 | public readonly Promise Promise;
6 |
7 | public Deferrer(Promise promise)
8 | {
9 | Promise = promise;
10 | }
11 |
12 | public void Resolve(object data)
13 | {
14 | Promise.PendThen(data);
15 | }
16 |
17 | public void Reject(string reason)
18 | {
19 | Promise.PendError(reason);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/ALE/FileSystem/AsyncFileReadState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace ALE.FileSystem
5 | {
6 | internal class AsyncFileReadState
7 | {
8 | public readonly Action Callback;
9 | public readonly FileStream FileStream;
10 | public byte[] Buffer;
11 |
12 | public AsyncFileReadState(Action callback, FileStream fs, byte[] buffer)
13 | {
14 | Callback = callback;
15 | FileStream = fs;
16 | Buffer = buffer;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/ALE.vsmdi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AleIISTest/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Backup/AleIISTest/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ALE/FileSystem/ReadAsyncCallbackState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace ALE.FileSystem
5 | {
6 | internal class ReadAsyncCallbackState
7 | {
8 | public readonly byte[] Buffer;
9 | public readonly Action Callback;
10 | public readonly FileStream FileStream;
11 | public long RemainingBytes;
12 |
13 | public ReadAsyncCallbackState(FileStream fs, byte[] buffer, Action callback)
14 | {
15 | FileStream = fs;
16 | Buffer = buffer;
17 | Callback = callback;
18 | RemainingBytes = fs.Length;
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/ALE.Http/IContext.cs:
--------------------------------------------------------------------------------
1 | using System.Security.Principal;
2 |
3 | namespace ALE.Http
4 | {
5 | public interface IContext
6 | {
7 | ///
8 | /// A data store to be leveraged by middleware for passing values between different stages of processing.
9 | ///
10 | dynamic ContextBag { get; set; }
11 |
12 | ///
13 | /// The response object.
14 | ///
15 | IResponse Response { get; }
16 |
17 | ///
18 | /// The requrest object.
19 | ///
20 | IRequest Request { get; }
21 |
22 | ///
23 | /// The user security information.
24 | ///
25 | IPrincipal User { get; }
26 | }
27 | }
--------------------------------------------------------------------------------
/ALE.Web/AleHttpHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Web;
3 |
4 | namespace ALE.Web
5 | {
6 | public class AleHttpHandler : IHttpAsyncHandler
7 | {
8 | #region IHttpAsyncHandler Members
9 |
10 | public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
11 | {
12 | var async = new AleHttpHandlerAsync(context, cb, extraData);
13 | async.StartWork();
14 | return async;
15 | }
16 |
17 | public void EndProcessRequest(IAsyncResult result)
18 | {
19 | }
20 |
21 | public bool IsReusable
22 | {
23 | get { return false; }
24 | }
25 |
26 |
27 | public void ProcessRequest(HttpContext context)
28 | {
29 | throw new InvalidOperationException();
30 | }
31 |
32 | #endregion
33 | }
34 | }
--------------------------------------------------------------------------------
/ALE.Web/Server.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ALE.Http;
3 | using ALE.Views;
4 |
5 | namespace ALE.Web
6 | {
7 | public class Server : ServerBase
8 | {
9 | private static Server _instance;
10 |
11 | private Server()
12 | {
13 | }
14 |
15 | public static Server Create()
16 | {
17 | if (_instance == null)
18 | {
19 | _instance = new Server();
20 | }
21 | return _instance;
22 | }
23 |
24 | public new Server Use(Action processor)
25 | {
26 | return (Server) base.Use(processor);
27 | }
28 |
29 | public new Server Use(IViewProcessor viewProcessor)
30 | {
31 | return (Server) base.Use(viewProcessor);
32 | }
33 |
34 | internal void Execute(IContext context)
35 | {
36 | this.OnProcess(context);
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/ALE.Http/IRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.Specialized;
4 | using System.IO;
5 | using System.Net;
6 | using System.Text;
7 |
8 | namespace ALE.Http
9 | {
10 | public interface IRequest
11 | {
12 | IContext Context { get; }
13 | IEnumerable AcceptTypes { get; }
14 | Encoding ContentEncoding { get; }
15 | long ContentLength { get; }
16 | string ContentType { get; }
17 | CookieCollection Cookies { get; }
18 | Stream InputStream { get; }
19 | string Method { get; }
20 | NameValueCollection Headers { get; }
21 | bool IsAuthenticated { get; }
22 | bool IsLocal { get; }
23 | Uri Url { get; }
24 | Uri UrlReferer { get; }
25 | string UserAgent { get; }
26 | IEnumerable UserLanguages { get; }
27 | }
28 | }
--------------------------------------------------------------------------------
/ALE.Http/Routing.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MS.Internal.Xml.XPath;
5 | using System.Linq.Expressions;
6 | using System.Reflection;
7 |
8 | namespace ALE.Http
9 | {
10 | public class Routing
11 | {
12 | ///
13 | /// Holds all routes to be checked.
14 | ///
15 | public static readonly List Routes = new List();
16 |
17 | public static void Handler(IContext context, Action next)
18 | {
19 | foreach (var route in Routes)
20 | {
21 | if (route.TryExecute(context, next))
22 | {
23 | break;
24 | }
25 | }
26 | }
27 |
28 | public static void Add(string path, Type controllerType, string methodName)
29 | {
30 | Routes.Add(new Route(path, methodName, controllerType));
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ALE.Tests/Http/Routing_Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 | using ALE.Http;
7 |
8 | namespace ALE.Tests.Http
9 | {
10 | [TestClass]
11 | public class Routing_Tests
12 | {
13 | [TestMethod]
14 | public void Route_GetParameters()
15 | {
16 | const string path = "/:controller/:action/:id";
17 | var parameters = Route.GetParameters(path);
18 | Assert.AreEqual(3, parameters.Length);
19 | Assert.AreEqual("controller", parameters[0]);
20 | Assert.AreEqual("action", parameters[1]);
21 | Assert.AreEqual("id", parameters[2]);
22 | }
23 |
24 | [TestMethod]
25 | public void Route_CreatePathTester()
26 | {
27 | const string path = "/:controller/:action/:id";
28 | var pathTester = Route.CreatePathTester(path);
29 | var pattern = pathTester.ToString();
30 | Assert.AreEqual(@"^/(?.+)/(?.+)/(?.+)", pattern);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ALE.Http/IResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Specialized;
2 | using System.IO;
3 | using System.Net;
4 | using System.Text;
5 | using System;
6 | using ALE.Views;
7 |
8 | namespace ALE.Http
9 | {
10 | public interface IResponse
11 | {
12 | IContext Context { get; }
13 | string ContentType { get; set; }
14 | Encoding ContentEncoding { get; set; }
15 | CookieCollection Cookies { get; }
16 | NameValueCollection Headers { get; }
17 | Stream OutputStream { get; }
18 | string RedirectLocation { get; set; }
19 | int StatusCode { get; set; }
20 | string StatusDescription { get; set; }
21 | IViewProcessor ViewProcessor { get; set; }
22 |
23 | void AddHeader(string name, string value);
24 | void AppendCookie(Cookie cookie);
25 | void AppendHeader(string name, string value);
26 | IResponse Write(string text);
27 | IResponse Write(byte[] binary);
28 | void Send();
29 | void Redirect(string location);
30 | IResponse Render(string view, object model, Action callback);
31 | }
32 | }
--------------------------------------------------------------------------------
/ALE.Http/ListenerContext.cs:
--------------------------------------------------------------------------------
1 | using System.Dynamic;
2 | using System.Net;
3 | using System.Security.Principal;
4 |
5 | namespace ALE.Http
6 | {
7 | public class ListenerContext : IContext
8 | {
9 | protected readonly HttpListenerContext InnerContext;
10 |
11 | private dynamic _contextBag = new ExpandoObject();
12 |
13 | internal ListenerContext(HttpListenerContext context)
14 | {
15 | InnerContext = context;
16 | Request = new ListenerRequest(context.Request, this);
17 | Response = new ListenerResponse(context.Response, this);
18 | User = context.User;
19 | }
20 |
21 | #region IContext Members
22 |
23 | public dynamic ContextBag
24 | {
25 | get { return _contextBag; }
26 | set { _contextBag = value; }
27 | }
28 |
29 | public IPrincipal User { get; private set; }
30 | public IRequest Request { get; private set; }
31 | public IResponse Response { get; private set; }
32 |
33 | public bool IsExecutionComplete { get; private set; }
34 |
35 | public void Complete()
36 | {
37 | IsExecutionComplete = true;
38 | }
39 |
40 | #endregion
41 | }
42 | }
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 Ben Lesh
2 | ben@benlesh.com
3 | http://www.benlesh.com
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/ALE.Web/AleContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Dynamic;
3 | using System.Security.Principal;
4 | using System.Web;
5 | using ALE.Http;
6 |
7 | namespace ALE.Web
8 | {
9 | public class AleContext : IContext
10 | {
11 | public readonly HttpContext InnerContext;
12 | private ExpandoObject _contextBag = new ExpandoObject();
13 |
14 | public AleContext(HttpContext innerContext)
15 | {
16 | if (innerContext == null) throw new ArgumentNullException("innerContext");
17 | InnerContext = innerContext;
18 | Response = new AleResponse(innerContext.Response, this);
19 | Request = new AleRequest(innerContext.Request, this);
20 | }
21 |
22 | #region IContext Members
23 |
24 | public dynamic ContextBag
25 | {
26 | get { return _contextBag; }
27 | set { _contextBag = value; }
28 | }
29 |
30 | public IResponse Response { get; private set; }
31 |
32 | public IRequest Request { get; private set; }
33 |
34 | public IPrincipal User { get; private set; }
35 |
36 | public bool IsExecutionComplete { get; private set; }
37 |
38 | public void Complete()
39 | {
40 | Response.Send();
41 | IsExecutionComplete = true;
42 | }
43 |
44 | #endregion
45 | }
46 | }
--------------------------------------------------------------------------------
/AleIISTest/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/Backup/AleIISTest/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/ALE.ConsoleTest/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Net;
6 | using ALE.Http;
7 | using System.Threading;
8 | using ALE.Tcp;
9 | using System.Diagnostics;
10 | using ALE.FileSystem;
11 | using ALE.Views.Razor;
12 |
13 | namespace ALE.ConsoleTest
14 | {
15 | class TestController : Controller
16 | {
17 | public void Test(Action next)
18 | {
19 | Response.Write("TestController.Test");
20 | next();
21 | }
22 |
23 | public void Foo(Action next, string foo)
24 | {
25 | Response.Render("ViewTest.cshtml", new TestModel {Title = foo}, (ex) => next());
26 | }
27 | }
28 |
29 | public class TestModel
30 | {
31 | public string Title { get; set; }
32 | }
33 | internal class Program
34 | {
35 | private static void Main(string[] args)
36 | {
37 | Routing.Add("/Test", typeof(TestController), "Test");
38 | Routing.Add("/Foo/:foo", typeof(TestController), "Foo");
39 | EventLoop.Start(() => Server.Create()
40 | .Use(RazorView.Default)
41 | .Use(Routing.Handler)
42 | .Use(Static.Directory("/public"))
43 | .Listen("http://*:1337/"));
44 | Console.ReadKey();
45 |
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ALE/EventLoopWorker.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 |
4 | namespace ALE
5 | {
6 | public class EventLoopWorker
7 | {
8 | private Task _worker;
9 |
10 | public readonly ManualResetEvent StopHandle = new ManualResetEvent(false);
11 |
12 | public bool Idle { get; private set; }
13 |
14 | public void Start()
15 | {
16 | StopHandle.Reset();
17 | _worker.ContinueWith(Work);
18 | }
19 |
20 | public void Stop()
21 | {
22 | StopHandle.Set();
23 | }
24 |
25 | public void Wait()
26 | {
27 | _worker.Wait();
28 | }
29 |
30 | public EventLoopWorker()
31 | {
32 | _worker = Task.Factory.StartNew(() => { });
33 | }
34 |
35 | private void Work(Task incomingTask)
36 | {
37 | if (StopHandle.WaitOne(0))
38 | {
39 | return;
40 | }
41 | var evt = EventLoop.NextEvent();
42 | if (evt != null)
43 | {
44 | Idle = false;
45 | _worker = incomingTask.ContinueWith(w2 => evt());
46 | _worker.ContinueWith(Work);
47 | } else
48 | {
49 | Idle = true;
50 | }
51 | incomingTask.Dispose();
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/AleIISTest/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/Backup/AleIISTest/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/ALE.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ALE.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ALE.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ff39fc0f-8875-42f4-b634-0185663864c7")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/AleIISTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("AleIISTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("AleIISTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0bedb3eb-ac9d-4000-b520-dd76a7a348ca")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Backup/AleIISTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("AleIISTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("AleIISTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0bedb3eb-ac9d-4000-b520-dd76a7a348ca")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/ALE.Web/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("ALE.Web")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ALE.Web")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("3ebabb16-b477-47d0-a23a-947ef0db6fa3")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/ALE/Tcp/WebSocketServer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Net.Sockets;
4 |
5 | namespace ALE.Tcp
6 | {
7 | public class WebSocketServer
8 | {
9 | public readonly Action Callback;
10 | public string IP;
11 | public string Origin;
12 | public int Port;
13 |
14 | public WebSocketServer(Action callback)
15 | {
16 | if (callback == null) throw new ArgumentNullException("callback");
17 | Callback = callback;
18 | }
19 |
20 | public void Listen(string ip, int port, string origin)
21 | {
22 | var address = IPAddress.Parse(ip);
23 | var listener = new TcpListener(address, port);
24 | IP = ip;
25 | Port = port;
26 | Origin = origin;
27 | listener.Start();
28 | listener.BeginAcceptTcpClient(AcceptTcpClientCallback, listener);
29 | }
30 |
31 | private void AcceptTcpClientCallback(IAsyncResult result)
32 | {
33 | var listener = (TcpListener)result.AsyncState;
34 |
35 | //get the tcpClient and create a new WebSocket object.
36 | var tcpClient = listener.EndAcceptTcpClient(result);
37 | var websocket = new WebSocket(this, tcpClient);
38 | websocket.BeginRead();
39 | //listen for the next connection.
40 | listener.BeginAcceptTcpClient(AcceptTcpClientCallback, listener);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/ALE/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("ALE")]
9 | [assembly: AssemblyDescription("Mmm... beer.")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ALE")]
13 | [assembly: AssemblyCopyright("Copyright © Ben Lesh 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("a4466b23-0abc-475a-a471-593d19cec92f")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("0.0.10.2")]
39 | [assembly: AssemblyFileVersion("0.0.10.2")]
--------------------------------------------------------------------------------
/ALE.Sql/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ALE.Sql")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ALE.Sql")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("2bedde48-bb75-4171-9f5a-785c6ff7a0d3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ALE.Http/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ALE.Http")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ALE.Http")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b175ac4e-6d0a-4e9a-ad14-388d3d2dbc24")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ALE.ConsoleTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ALE.ConsoleTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ALE.ConsoleTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b0bbe64f-c0ae-477c-964b-0c6d5005b5b8")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ALE.Views.Razor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ALE.Views.Razor")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ALE.Views.Razor")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("d1893a20-fe01-4e05-8892-11a07bdf6341")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AleIISTest/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Security;
6 | using System.Web.SessionState;
7 | using ALE;
8 |
9 | namespace AleIISTest
10 | {
11 | public class Global : System.Web.HttpApplication
12 | {
13 |
14 | void Application_Start(object sender, EventArgs e)
15 | {
16 | // Start the event loop.
17 | EventLoop.Start();
18 |
19 | // Get the ALE server instance and wire up your middlware.
20 | ALE.Web.Server.Create()
21 | .Use((context, next) =>
22 | {
23 | context.Response.Write("Hello World");
24 | next();
25 | })
26 | .Use((context, next) =>
27 | {
28 | context.Response.Write("
No seriously, I said hello.");
29 | next();
30 | });
31 | }
32 |
33 | void Application_End(object sender, EventArgs e)
34 | {
35 | // Shut down the EventLoop.
36 | EventLoop.Stop();
37 | }
38 |
39 | void Application_Error(object sender, EventArgs e)
40 | {
41 | // Code that runs when an unhandled error occurs
42 |
43 | }
44 |
45 | void Session_Start(object sender, EventArgs e)
46 | {
47 | // Code that runs when a new session is started
48 |
49 | }
50 |
51 | void Session_End(object sender, EventArgs e)
52 | {
53 | // Code that runs when a session ends.
54 | // Note: The Session_End event is raised only when the sessionstate mode
55 | // is set to InProc in the Web.config file. If session mode is set to StateServer
56 | // or SQLServer, the event is not raised.
57 |
58 | }
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Backup/AleIISTest/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Security;
6 | using System.Web.SessionState;
7 | using ALE;
8 |
9 | namespace AleIISTest
10 | {
11 | public class Global : System.Web.HttpApplication
12 | {
13 |
14 | void Application_Start(object sender, EventArgs e)
15 | {
16 | // Start the event loop.
17 | EventLoop.Start();
18 |
19 | // Get the ALE server instance and wire up your middlware.
20 | ALE.Web.Server.Create()
21 | .Use((context, next) =>
22 | {
23 | context.Response.Write("Hello World");
24 | next();
25 | })
26 | .Use((context, next) =>
27 | {
28 | context.Response.Write("
No seriously, I said hello.");
29 | next();
30 | });
31 | }
32 |
33 | void Application_End(object sender, EventArgs e)
34 | {
35 | // Shut down the EventLoop.
36 | EventLoop.Stop();
37 | }
38 |
39 | void Application_Error(object sender, EventArgs e)
40 | {
41 | // Code that runs when an unhandled error occurs
42 |
43 | }
44 |
45 | void Session_Start(object sender, EventArgs e)
46 | {
47 | // Code that runs when a new session is started
48 |
49 | }
50 |
51 | void Session_End(object sender, EventArgs e)
52 | {
53 | // Code that runs when a session ends.
54 | // Note: The Session_End event is raised only when the sessionstate mode
55 | // is set to InProc in the Web.config file. If session mode is set to StateServer
56 | // or SQLServer, the event is not raised.
57 |
58 | }
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/ALE/Tcp/WebSocketHandshake.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Security.Cryptography;
3 | using System.Text;
4 | using System.Text.RegularExpressions;
5 |
6 | namespace ALE.Tcp
7 | {
8 | public static class WebSocketHandshake
9 | {
10 | public static string GetHandshake(Encoding enc, string secKey, string ip, int port, string origin)
11 | {
12 | var writer = new StringBuilder();
13 | writer.AppendLine("HTTP/1.1 101 Web Socket Protocol Handshake");
14 | writer.AppendLine("Upgrade: websocket");
15 | writer.AppendLine("Connection: Upgrade");
16 | writer.AppendLine("WebSocket-Origin: " + origin);
17 | writer.AppendLine("WebSocket-Location: ws://" + ip + ":" + port + "/ale");
18 | if (!String.IsNullOrEmpty(secKey))
19 | {
20 | writer.AppendLine("Sec-WebSocket-Accept: " + HashSecKey(enc, secKey));
21 | }
22 | writer.AppendLine("");
23 | return writer.ToString();
24 | }
25 |
26 | public static string GetSecKey(string clientHandshake)
27 | {
28 | var regSecKey = new Regex(@"Sec-WebSocket-Key: (.*?)\r\n");
29 | var match = regSecKey.Match(clientHandshake);
30 | if (match == null) return String.Empty;
31 | return match.Groups[1].Value;
32 | }
33 |
34 | public static string HashSecKey(Encoding enc, string secKey)
35 | {
36 | using (var sha1 = new SHA1Managed())
37 | {
38 | var hash = sha1.ComputeHash(enc.GetBytes(secKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"));
39 | return Convert.ToBase64String(hash);
40 | }
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/ALE.Web/AleHttpHandlerAsync.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Web;
4 |
5 | namespace ALE.Web
6 | {
7 | internal class AleHttpHandlerAsync : IAsyncResult
8 | {
9 | private readonly AsyncCallback _callback;
10 | private readonly bool _completed;
11 | private readonly HttpContext _context;
12 | private readonly object _extraData;
13 |
14 | public AleHttpHandlerAsync(HttpContext context, AsyncCallback callback, object extraData)
15 | {
16 | _context = context;
17 | _callback = callback;
18 | _extraData = extraData;
19 | _completed = false;
20 | }
21 |
22 | public object AsyncState
23 | {
24 | get { return _extraData; }
25 | }
26 |
27 | public WaitHandle AsyncWaitHandle
28 | {
29 | get { return null; }
30 | }
31 |
32 | public bool CompletedSynchronously
33 | {
34 | get { return false; }
35 | }
36 |
37 | public bool IsCompleted
38 | {
39 | get { return _completed; }
40 | }
41 |
42 | public void StartWork()
43 | {
44 | ThreadPool.QueueUserWorkItem(DoWork);
45 | }
46 |
47 | private void DoWork(object workItemState)
48 | {
49 | var aleContext = new AleContext(_context);
50 | EventLoop.Pend(() =>
51 | {
52 | Server.Create().Execute(aleContext);
53 | if (_callback != null)
54 | {
55 | _callback(this);
56 | }
57 | });
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/TraceAndTestImpact.testsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | These are test settings for Trace and Test Impact.
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ALE/Promise.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ALE
7 | {
8 | public class Promise
9 | {
10 | protected readonly List> ThenCallbacks = new List>();
11 | protected readonly List> ErrorCallbacks = new List>();
12 |
13 | public static Promise When(params Promise[] promises)
14 | {
15 | var i = promises.Length;
16 | return new Promise((deferrer) =>
17 | {
18 | foreach (var promise in promises)
19 | {
20 | promise.Then((data) =>
21 | {
22 | if (--i == 0)
23 | {
24 | deferrer.Resolve(data);
25 | }
26 | }).Error(deferrer.Reject);
27 | }
28 | });
29 | }
30 |
31 | public static Promise To(Action act)
32 | {
33 | return new Promise(act);
34 | }
35 |
36 | private Promise(Action act)
37 | {
38 | var deferrer = new Deferrer(this);
39 | act(deferrer);
40 | }
41 |
42 | internal void PendThen(object result)
43 | {
44 | foreach (var thenCallback in ThenCallbacks)
45 | {
46 | var callback = thenCallback;
47 | EventLoop.Pend(() => callback(result));
48 | }
49 | }
50 |
51 | internal void PendError(string reason)
52 | {
53 | foreach (var errorCallback in ErrorCallbacks)
54 | {
55 | var callback = errorCallback;
56 | EventLoop.Pend(() => callback(reason));
57 | }
58 | }
59 |
60 | public Promise Then(Action