├── 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 callback) 61 | { 62 | ThenCallbacks.Add(callback); 63 | return this; 64 | } 65 | 66 | public Promise Error(Action callback) 67 | { 68 | ErrorCallbacks.Add(callback); 69 | return this; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ALE.Web/AleRequest.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 | using System.Web; 8 | using ALE.Http; 9 | 10 | namespace ALE.Web 11 | { 12 | public class AleRequest : IRequest 13 | { 14 | public readonly HttpRequest InnerRequest; 15 | 16 | public AleRequest(HttpRequest innerRequest, IContext context) 17 | { 18 | if(innerRequest == null) throw new ArgumentNullException("innerRequest"); 19 | if(context == null) throw new ArgumentNullException("context"); 20 | InnerRequest = innerRequest; 21 | Context = context; 22 | } 23 | 24 | #region IRequest Members 25 | 26 | public IContext Context { get; private set; } 27 | 28 | public IEnumerable AcceptTypes 29 | { 30 | get { return InnerRequest.AcceptTypes; } 31 | } 32 | 33 | public Encoding ContentEncoding 34 | { 35 | get { return InnerRequest.ContentEncoding; } 36 | } 37 | 38 | public long ContentLength 39 | { 40 | get { return InnerRequest.ContentLength; } 41 | } 42 | 43 | public string ContentType 44 | { 45 | get { return InnerRequest.ContentType; } 46 | } 47 | 48 | public CookieCollection Cookies 49 | { 50 | get { throw new NotImplementedException("Sorry, I'm working on this."); } 51 | } 52 | 53 | public Stream InputStream 54 | { 55 | get { return InnerRequest.InputStream; } 56 | } 57 | 58 | public string Method 59 | { 60 | get { return InnerRequest.HttpMethod; } 61 | } 62 | 63 | public NameValueCollection Headers 64 | { 65 | get { return InnerRequest.Headers; } 66 | } 67 | 68 | public bool IsAuthenticated 69 | { 70 | get { return InnerRequest.IsAuthenticated; } 71 | } 72 | 73 | public bool IsLocal 74 | { 75 | get { return InnerRequest.IsLocal; } 76 | } 77 | 78 | public Uri Url 79 | { 80 | get { return InnerRequest.Url; } 81 | } 82 | 83 | public Uri UrlReferer 84 | { 85 | get { return InnerRequest.UrlReferrer; } 86 | } 87 | 88 | public string UserAgent 89 | { 90 | get { return InnerRequest.UserAgent; } 91 | } 92 | 93 | public IEnumerable UserLanguages 94 | { 95 | get { return InnerRequest.UserLanguages; } 96 | } 97 | 98 | #endregion 99 | } 100 | } -------------------------------------------------------------------------------- /ALE.Views.Razor/RazorView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ALE.FileSystem; 6 | using System.IO; 7 | using RazorEngine.Templating; 8 | 9 | namespace ALE.Views.Razor 10 | { 11 | public class RazorView : IViewProcessor 12 | { 13 | public static RazorView Default { get { return new RazorView("/Views"); } } 14 | public static RazorView Processor(string path) 15 | { 16 | return new RazorView(path); 17 | } 18 | 19 | protected readonly string ViewsDirectoryPath; 20 | protected readonly string ViewsRoot; 21 | 22 | private RazorView(string viewsDirPath) 23 | { 24 | ViewsDirectoryPath = viewsDirPath; 25 | ViewsRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, 26 | ViewsDirectoryPath.Replace('/', '\\').TrimStart('\\')); 27 | } 28 | 29 | protected void LoadView(string view, Action callback) 30 | { 31 | var deUrled = view.Replace('/', '\\').TrimStart('\\'); 32 | var viewFile = Path.Combine(ViewsRoot, deUrled); 33 | if (!System.IO.File.Exists(viewFile)) 34 | { 35 | throw new FileNotFoundException("View not found."); 36 | } 37 | FileSystem.File.ReadAllText(viewFile, (ex, text) => EventLoop.Pend(() => callback(ex, text))); 38 | } 39 | 40 | public void Render(string view, object model, Action callback) 41 | { 42 | LoadView(view, (ex, viewtext) => 43 | { 44 | if (ex != null) 45 | { 46 | EventLoop.Pend(() => callback(ex, null)); 47 | } 48 | try 49 | { 50 | var result = RazorEngine.Razor.Parse(viewtext, model); 51 | EventLoop.Pend(() => callback(null, result)); 52 | } catch (Exception ex2) 53 | { 54 | EventLoop.Pend(() => callback(ex2, null)); 55 | } 56 | }); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ALE.Http/ListenerRequest.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 | internal class ListenerRequest : IRequest 11 | { 12 | protected readonly HttpListenerRequest InnerRequest; 13 | 14 | private readonly IContext _context; 15 | 16 | internal ListenerRequest(HttpListenerRequest innerRequest, IContext context) 17 | { 18 | if (innerRequest == null) throw new ArgumentNullException("innerRequest"); 19 | if (context == null) throw new ArgumentNullException("context"); 20 | InnerRequest = innerRequest; 21 | _context = context; 22 | } 23 | 24 | public bool HasBody 25 | { 26 | get { return InnerRequest.HasEntityBody; } 27 | } 28 | 29 | #region IRequest Members 30 | 31 | public IContext Context 32 | { 33 | get { return _context; } 34 | } 35 | 36 | public IEnumerable AcceptTypes 37 | { 38 | get { return InnerRequest.AcceptTypes; } 39 | } 40 | 41 | public Encoding ContentEncoding 42 | { 43 | get { return InnerRequest.ContentEncoding; } 44 | } 45 | 46 | public long ContentLength 47 | { 48 | get { return InnerRequest.ContentLength64; } 49 | } 50 | 51 | public string ContentType 52 | { 53 | get { return InnerRequest.ContentType; } 54 | } 55 | 56 | public CookieCollection Cookies 57 | { 58 | get { return InnerRequest.Cookies; } 59 | } 60 | 61 | public Stream InputStream 62 | { 63 | get { return InnerRequest.InputStream; } 64 | } 65 | 66 | public string Method 67 | { 68 | get { return InnerRequest.HttpMethod; } 69 | } 70 | 71 | public NameValueCollection Headers 72 | { 73 | get { return InnerRequest.Headers; } 74 | } 75 | 76 | public bool IsAuthenticated 77 | { 78 | get { return InnerRequest.IsAuthenticated; } 79 | } 80 | 81 | public bool IsLocal 82 | { 83 | get { return InnerRequest.IsLocal; } 84 | } 85 | 86 | public Uri Url 87 | { 88 | get { return InnerRequest.Url; } 89 | } 90 | 91 | public Uri UrlReferer 92 | { 93 | get { return InnerRequest.UrlReferrer; } 94 | } 95 | 96 | public string UserAgent 97 | { 98 | get { return InnerRequest.UserAgent; } 99 | } 100 | 101 | public IEnumerable UserLanguages 102 | { 103 | get { return InnerRequest.UserLanguages; } 104 | } 105 | 106 | #endregion 107 | } 108 | } -------------------------------------------------------------------------------- /ALE.Sql/ALE.Sql.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {54C95345-6D76-485F-927E-6B5C78DBE639} 9 | Library 10 | Properties 11 | ALE.Sql 12 | ALE.Sql 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | {48CE219E-2D15-46D8-889F-52E04D110097} 49 | ALE 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /ALE/FileSystem/FileSystemWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | namespace ALE.FileSystem 8 | { 9 | public class FileSystemWatcher : IDisposable 10 | { 11 | private readonly System.IO.FileSystemWatcher _fsw; 12 | 13 | public string Filter 14 | { 15 | get { return _fsw.Filter; } 16 | set { _fsw.Filter = value; } 17 | } 18 | 19 | public string Path 20 | { 21 | get { return _fsw.Path; } 22 | set { _fsw.Path = value; } 23 | } 24 | 25 | public static FileSystemWatcher Watch(string path, string filter = null) 26 | { 27 | var fsw = new FileSystemWatcher(path, filter); 28 | return fsw.Start(); 29 | } 30 | 31 | private FileSystemWatcher(string path, string filter) 32 | { 33 | if (!String.IsNullOrWhiteSpace(filter)) 34 | { 35 | _fsw = new System.IO.FileSystemWatcher(path, filter); 36 | } else 37 | { 38 | _fsw = new System.IO.FileSystemWatcher(path); 39 | } 40 | } 41 | 42 | public FileSystemWatcher Changed(Action callback) 43 | { 44 | _fsw.Changed += (sender, args) => EventLoop.Pend(() => callback(args.FullPath)); 45 | return this; 46 | } 47 | 48 | public FileSystemWatcher Deleted(Action callback) 49 | { 50 | _fsw.Deleted += (sender, args) => EventLoop.Pend(() => callback(args.FullPath)); 51 | return this; 52 | } 53 | 54 | public FileSystemWatcher Created(Action callback) 55 | { 56 | _fsw.Created += (sender, args) => EventLoop.Pend(() => callback(args.FullPath)); 57 | return this; 58 | } 59 | 60 | public FileSystemWatcher Renamed(Action callback) 61 | { 62 | _fsw.Renamed += (sender, args) => EventLoop.Pend(() => callback(args.FullPath, args.OldFullPath)); 63 | return this; 64 | } 65 | 66 | public FileSystemWatcher Start() 67 | { 68 | _fsw.EnableRaisingEvents = true; 69 | return this; 70 | } 71 | 72 | public FileSystemWatcher Stop() 73 | { 74 | _fsw.EnableRaisingEvents = false; 75 | return this; 76 | } 77 | 78 | ~FileSystemWatcher() 79 | { 80 | Dispose(); 81 | } 82 | 83 | public void Dispose() 84 | { 85 | if (_fsw != null) 86 | { 87 | _fsw.Dispose(); 88 | } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /_UpgradeReport_Files/UpgradeReport.css: -------------------------------------------------------------------------------- 1 | /* Body style, for the entire document */ 2 | body 3 | { 4 | background: #F3F3F4; 5 | color: #1E1E1F; 6 | font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; 7 | padding: 0; 8 | margin: 0; 9 | } 10 | 11 | /* Header1 style, used for the main title */ 12 | h1 13 | { 14 | padding: 10px 0px 10px 10px; 15 | font-size: 21pt; 16 | background-color: #E2E2E2; 17 | border-bottom: 1px #C1C1C2 solid; 18 | color: #201F20; 19 | margin: 0; 20 | font-weight: normal; 21 | } 22 | 23 | /* Header2 style, used for "Overview" and other sections */ 24 | h2 25 | { 26 | font-size: 18pt; 27 | font-weight: normal; 28 | padding: 15px 0 5px 0; 29 | margin: 0; 30 | } 31 | 32 | /* Header3 style, used for sub-sections, such as project name */ 33 | h3 34 | { 35 | font-weight: normal; 36 | font-size: 15pt; 37 | margin: 0; 38 | padding: 15px 0 5px 0; 39 | background-color: transparent; 40 | } 41 | 42 | /* Color all hyperlinks one color */ 43 | a 44 | { 45 | color: #1382CE; 46 | } 47 | 48 | /* Table styles */ 49 | table 50 | { 51 | border-spacing: 0 0; 52 | border-collapse: collapse; 53 | font-size: 10pt; 54 | } 55 | 56 | table th 57 | { 58 | background: #E7E7E8; 59 | text-align: left; 60 | text-decoration: none; 61 | font-weight: normal; 62 | padding: 3px 6px 3px 6px; 63 | } 64 | 65 | table td 66 | { 67 | vertical-align: top; 68 | padding: 3px 6px 5px 5px; 69 | margin: 0px; 70 | border: 1px solid #E7E7E8; 71 | background: #F7F7F8; 72 | } 73 | 74 | /* Local link is a style for hyperlinks that link to file:/// content, there are lots so color them as 'normal' text until the user mouse overs */ 75 | .localLink 76 | { 77 | color: #1E1E1F; 78 | background: #EEEEED; 79 | text-decoration: none; 80 | } 81 | 82 | .localLink:hover 83 | { 84 | color: #1382CE; 85 | background: #FFFF99; 86 | text-decoration: none; 87 | } 88 | 89 | /* Center text, used in the over views cells that contain message level counts */ 90 | .textCentered 91 | { 92 | text-align: center; 93 | } 94 | 95 | /* The message cells in message tables should take up all avaliable space */ 96 | .messageCell 97 | { 98 | width: 100%; 99 | } 100 | 101 | /* Padding around the content after the h1 */ 102 | #content 103 | { 104 | padding: 0px 12px 12px 12px; 105 | } 106 | 107 | /* The overview table expands to width, with a max width of 97% */ 108 | #overview table 109 | { 110 | width: auto; 111 | max-width: 75%; 112 | } 113 | 114 | /* The messages tables are always 97% width */ 115 | #messages table 116 | { 117 | width: 97%; 118 | } -------------------------------------------------------------------------------- /ALE.Tests/Do_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 System.Diagnostics; 7 | using System.Threading; 8 | 9 | namespace ALE.Tests 10 | { 11 | [TestClass] 12 | public class Do_Tests 13 | { 14 | [TestMethod] 15 | public void Do_Timeout() 16 | { 17 | var sw = Stopwatch.StartNew(); 18 | const int ms = 100; 19 | var i = 0; 20 | var ellapsed = 0L; 21 | var wait = new AutoResetEvent(false); 22 | Do.Timeout(() => 23 | { 24 | ellapsed = sw.ElapsedMilliseconds; 25 | i++; 26 | wait.Set(); 27 | }, ms); 28 | if (wait.WaitOne(ms * 3)) 29 | { 30 | Assert.AreEqual(1, i); 31 | Assert.IsTrue(ellapsed > ms * .9); 32 | } else 33 | { 34 | Assert.Fail("callback not executed."); 35 | } 36 | 37 | sw.Restart(); 38 | var killswitch = Do.Timeout(() => { wait.Set(); }, ms * 2); 39 | killswitch.Kill(); 40 | ellapsed = sw.ElapsedMilliseconds; 41 | Assert.IsTrue(ellapsed < ms * 2); 42 | if (wait.WaitOne(ms * 4)) 43 | { 44 | Assert.Fail("Unable to stop timeout."); 45 | } 46 | } 47 | 48 | [TestMethod] 49 | public void Do_Interval() 50 | { 51 | var sw = Stopwatch.StartNew(); 52 | var i = 0; 53 | var elapsed = 0L; 54 | var wait = new AutoResetEvent(false); 55 | const int intervalTime = 100; 56 | var killswitch = Do.Interval(() => 57 | { 58 | i++; 59 | if (i == 3) 60 | { 61 | elapsed = sw.ElapsedMilliseconds; 62 | wait.Set(); 63 | } 64 | }, intervalTime); 65 | if (wait.WaitOne(intervalTime * 5)) 66 | { 67 | killswitch.Kill(); 68 | var testMS = intervalTime * .9m; 69 | Assert.IsTrue(elapsed > testMS, "Elapsed time is greater than " + testMS + " ms. (" + elapsed + ")"); 70 | Assert.AreEqual(3, i, "Too many executions."); 71 | } else 72 | { 73 | Assert.Fail("interval not executed properly. Timeout occurred."); 74 | } 75 | Thread.Sleep(intervalTime * 2); 76 | Assert.AreEqual(3, i, "interval not dead."); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /ALE/EventLoop.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Collections.Concurrent; 6 | using System.Threading.Tasks; 7 | 8 | namespace ALE 9 | { 10 | public class EventLoop 11 | { 12 | protected static ConcurrentQueue TaskQueue = new ConcurrentQueue(); 13 | protected readonly static List Workers = new List(); 14 | public static bool IsRunning { get; private set; } 15 | public static int PendingEventCount 16 | { 17 | get { return TaskQueue.Count; } 18 | } 19 | 20 | public static int IdleWorkerCount 21 | { 22 | get { return Workers.Count(x => x.Idle); } 23 | } 24 | 25 | public static int WorkerCount 26 | { 27 | get { return Workers.Count; } 28 | } 29 | 30 | public static void Start(Action startEvent) 31 | { 32 | if (startEvent != null) 33 | { 34 | Pend(startEvent); 35 | } 36 | } 37 | 38 | public static void Start() 39 | { 40 | IsRunning = true; 41 | if (Workers.Count == 0) 42 | { 43 | AddWorker(); 44 | } else 45 | { 46 | Workers.ForEach(x => x.Start()); 47 | } 48 | } 49 | 50 | public static void RemoveWorker() 51 | { 52 | lock (Workers) 53 | { 54 | var worker = Workers.Last(); 55 | worker.Stop(); 56 | worker.Wait(); 57 | Workers.Remove(worker); 58 | } 59 | } 60 | 61 | public static void AddWorker() 62 | { 63 | lock (Workers) 64 | { 65 | var worker = new EventLoopWorker(); 66 | if (IsRunning) 67 | { 68 | worker.Start(); 69 | } 70 | Workers.Add(worker); 71 | } 72 | } 73 | 74 | public static Action NextEvent() 75 | { 76 | Action evt; 77 | if (TaskQueue.TryDequeue(out evt)) 78 | { 79 | return evt; 80 | } 81 | return null; 82 | } 83 | 84 | public static void Pend(Action evt) 85 | { 86 | TaskQueue.Enqueue(evt); 87 | Start(); 88 | } 89 | 90 | public static void Stop() 91 | { 92 | Workers.ForEach(x => x.Stop()); 93 | Workers.ForEach(x => x.Wait()); 94 | IsRunning = false; 95 | } 96 | 97 | /// 98 | /// Clears all queued events. 99 | /// 100 | public static void Clear() 101 | { 102 | TaskQueue = new ConcurrentQueue(); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /ALE/ALE.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {48CE219E-2D15-46D8-889F-52E04D110097} 9 | Library 10 | Properties 11 | ALE 12 | ALE 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 67 | -------------------------------------------------------------------------------- /ALE.Web/ALE.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B} 9 | Library 10 | Properties 11 | ALE.Web 12 | ALE.Web 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {3CB804B8-474A-4399-8E69-12EBB533CBEC} 55 | ALE.Http 56 | 57 | 58 | {48CE219E-2D15-46D8-889F-52E04D110097} 59 | ALE 60 | 61 | 62 | 63 | 70 | -------------------------------------------------------------------------------- /ALE.Tests/Promise_Tests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace ALE.Tests 7 | { 8 | [TestClass] 9 | public class Promise_Tests 10 | { 11 | [TestMethod] 12 | public void Promise_Test1() 13 | { 14 | var list = new List(); 15 | var handle = new ManualResetEvent(false); 16 | EventLoop.Start(() => 17 | { 18 | Promise.To((deferrer) => 19 | { 20 | Do.Timeout(() => 21 | { 22 | list.Add(123); 23 | deferrer.Resolve(null); 24 | }, 300); 25 | 26 | }).Then((data) => 27 | { 28 | list.Add(456); 29 | handle.Set(); 30 | }); 31 | }); 32 | if(handle.WaitOne(4000)) 33 | { 34 | Assert.AreEqual(123, list[0]); 35 | Assert.AreEqual(456, list[1]); 36 | }else 37 | { 38 | Assert.Fail(); 39 | } 40 | EventLoop.Stop(); 41 | } 42 | 43 | [TestMethod] 44 | public void Future_When_Test() 45 | { 46 | int i = 0; 47 | Func createPromise = () => 48 | { 49 | return Promise.To((deferrer) => 50 | { 51 | Do.Timeout(() => 52 | { 53 | i++; 54 | deferrer.Resolve(null); 55 | }, 500); 56 | }); 57 | }; 58 | EventLoop.Start(); 59 | var handle = new ManualResetEvent(false); 60 | EventLoop.Start(() => 61 | { 62 | Promise.When(createPromise(), createPromise(), createPromise()) 63 | .Then((data) => 64 | { 65 | handle.Set(); 66 | }); 67 | }); 68 | 69 | if (handle.WaitOne(2000)) 70 | { 71 | Assert.AreEqual(3, i); 72 | }else 73 | { 74 | Assert.Fail(); 75 | } 76 | EventLoop.Stop(); 77 | } 78 | 79 | [TestMethod] 80 | public void PromiseError_Test() 81 | { 82 | var handle = new ManualResetEvent(false); 83 | Promise.To((deferrer) => 84 | { 85 | Do.Timeout(() => deferrer.Reject("Testing rejection."), 400); 86 | }).Error((reason) => 87 | { 88 | handle.Set(); 89 | }); 90 | if (!handle.WaitOne(600)) 91 | { 92 | Assert.Fail(); 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /ALE.Views.Razor/ALE.Views.Razor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B} 9 | Library 10 | Properties 11 | ALE.Views.Razor 12 | ALE.Views.Razor 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | ..\packages\RazorEngine.3.0.8\lib\net40\RazorEngine.dll 36 | 37 | 38 | 39 | 40 | True 41 | ..\packages\RazorEngine.3.0.8\lib\net40\System.Web.Razor.dll 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {48CE219E-2D15-46D8-889F-52E04D110097} 56 | ALE 57 | 58 | 59 | 60 | 61 | 62 | 63 | 70 | -------------------------------------------------------------------------------- /ALE.Http/ALE.Http.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {3CB804B8-474A-4399-8E69-12EBB533CBEC} 9 | Library 10 | Properties 11 | ALE.Http 12 | ALE.Http 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | {48CE219E-2D15-46D8-889F-52E04D110097} 62 | ALE 63 | 64 | 65 | 66 | 73 | -------------------------------------------------------------------------------- /ALE.ConsoleTest/ALE.ConsoleTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {7AEA9929-B496-425F-8F80-DE270504940A} 9 | Exe 10 | Properties 11 | ALE.ConsoleTest 12 | ALE.ConsoleTest 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | x86 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | x86 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | {3CB804B8-474A-4399-8E69-12EBB533CBEC} 52 | ALE.Http 53 | 54 | 55 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B} 56 | ALE.Views.Razor 57 | 58 | 59 | {48CE219E-2D15-46D8-889F-52E04D110097} 60 | ALE 61 | 62 | 63 | 64 | 65 | PreserveNewest 66 | 67 | 68 | 69 | 76 | -------------------------------------------------------------------------------- /ALE.Web/AleResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.IO; 4 | using System.Net; 5 | using System.Text; 6 | using System.Web; 7 | using ALE.Http; 8 | using ALE.Views; 9 | 10 | namespace ALE.Web 11 | { 12 | public class AleResponse : IResponse 13 | { 14 | public readonly HttpResponse InnerResponse; 15 | 16 | public AleResponse(HttpResponse innerResponse, IContext context) 17 | { 18 | if (innerResponse == null) throw new ArgumentNullException("innerResponse"); 19 | if (context == null) throw new ArgumentNullException("context"); 20 | InnerResponse = innerResponse; 21 | Context = context; 22 | ContentType = "text/html"; 23 | StatusCode = 200; //OK 24 | } 25 | 26 | public IContext Context { get; private set; } 27 | 28 | public string ContentType 29 | { 30 | get { return InnerResponse.ContentType; } 31 | set { InnerResponse.ContentType = value; } 32 | } 33 | 34 | public Encoding ContentEncoding 35 | { 36 | get { return InnerResponse.ContentEncoding; } 37 | set { InnerResponse.ContentEncoding = value; } 38 | } 39 | 40 | public CookieCollection Cookies 41 | { 42 | get { throw new NotImplementedException("Sorry"); } 43 | } 44 | 45 | public NameValueCollection Headers 46 | { 47 | get { return InnerResponse.Headers; } 48 | } 49 | 50 | public Stream OutputStream 51 | { 52 | get { return InnerResponse.OutputStream; } 53 | } 54 | 55 | public string RedirectLocation 56 | { 57 | get { return InnerResponse.RedirectLocation; } 58 | set { InnerResponse.RedirectLocation = value; } 59 | } 60 | 61 | public int StatusCode 62 | { 63 | get { return InnerResponse.StatusCode; } 64 | set { InnerResponse.StatusCode = value; } 65 | } 66 | 67 | public string StatusDescription 68 | { 69 | get { return InnerResponse.StatusDescription; } 70 | set { InnerResponse.StatusDescription = value; } 71 | } 72 | 73 | public IViewProcessor ViewProcessor { get; set; } 74 | 75 | public void AddHeader(string name, string value) 76 | { 77 | InnerResponse.AddHeader(name, value); 78 | } 79 | 80 | public void AppendCookie(Cookie cookie) 81 | { 82 | throw new NotImplementedException(); 83 | } 84 | 85 | public void AppendHeader(string name, string value) 86 | { 87 | InnerResponse.AppendHeader(name, value); 88 | } 89 | 90 | public IResponse Write(string text) 91 | { 92 | InnerResponse.Write(text); 93 | return this; 94 | } 95 | 96 | public IResponse Write(byte[] binary) 97 | { 98 | InnerResponse.BinaryWrite(binary); 99 | return this; 100 | } 101 | 102 | public void Send() 103 | { 104 | InnerResponse.Flush(); 105 | InnerResponse.Close(); 106 | } 107 | 108 | public void Redirect(string location) 109 | { 110 | InnerResponse.Redirect(location); 111 | } 112 | 113 | public IResponse Render(string view, object model, Action callback) 114 | { 115 | if (ViewProcessor == null) 116 | { 117 | throw new InvalidOperationException("ViewProcessor has not been set. Unable to render view."); 118 | } 119 | ViewProcessor.Render(view, model, (ex, rendered) => 120 | { 121 | if (ex != null && callback != null) 122 | { 123 | EventLoop.Pend(() => callback(ex)); 124 | return; 125 | } 126 | Write(rendered); 127 | }); 128 | return this; 129 | } 130 | } 131 | } -------------------------------------------------------------------------------- /ALE.Tests/ALE.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 7 | 8 | 2.0 9 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10} 10 | Library 11 | Properties 12 | ALE.Tests 13 | ALE.Tests 14 | v4.0 15 | 512 16 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 3.5 40 | 41 | 42 | 43 | 44 | False 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | {3CB804B8-474A-4399-8E69-12EBB533CBEC} 57 | ALE.Http 58 | 59 | 60 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B} 61 | ALE.Web 62 | 63 | 64 | {48CE219E-2D15-46D8-889F-52E04D110097} 65 | ALE 66 | 67 | 68 | 69 | 76 | -------------------------------------------------------------------------------- /ALE.Http/Route.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text.RegularExpressions; 6 | 7 | namespace ALE.Http 8 | { 9 | public class Route 10 | { 11 | public static readonly Regex PathParser = new Regex(@"\:(\w+?)(\W|$)"); 12 | public MethodInfo HandlerInfo; 13 | public readonly Dictionary HandlerParameters; 14 | public readonly string Path; 15 | public readonly Regex PathTester; 16 | public readonly string[] Parameters; 17 | public readonly Type ControllerType; 18 | 19 | public Route(string path, string methodName, Type controllerType) 20 | { 21 | if (String.IsNullOrWhiteSpace(path)) throw new ArgumentNullException("path"); 22 | if (String.IsNullOrWhiteSpace(methodName)) throw new ArgumentNullException("methodName"); 23 | Path = path; 24 | Parameters = GetParameters(path); 25 | PathTester = CreatePathTester(path); 26 | ControllerType = controllerType; 27 | HandlerInfo = controllerType.GetMethod(methodName); 28 | HandlerParameters = HandlerInfo.GetParameters().ToDictionary(x => x.Name, x => x); 29 | if (HandlerParameters.Count == 0 || HandlerParameters.First().Value.ParameterType != typeof(Action)) 30 | { 31 | throw new InvalidOperationException("First argument of a route must be the 'next' delegate."); 32 | } 33 | } 34 | 35 | public static string[] GetParameters(string path) 36 | { 37 | var matches = PathParser.Matches(path); 38 | var results = new string[matches.Count]; 39 | for (int i = 0; i < matches.Count; i++) 40 | { 41 | results[i] = matches[i].Groups[1].Value; 42 | } 43 | return results; 44 | } 45 | 46 | public static Regex CreatePathTester(string path) 47 | { 48 | var pattern = PathParser.Replace(path, m => "(?<" + m.Groups[1].Value + @">.+)" + m.Groups[2].Value); 49 | return new Regex("^" + pattern); 50 | } 51 | 52 | public bool TryExecute(IContext context, Action next) 53 | { 54 | var req = context.Request; 55 | var res = context.Response; 56 | var path = req.Url.PathAndQuery; 57 | var isMatch = PathTester.IsMatch(path); 58 | if (isMatch) 59 | { 60 | var match = PathTester.Match(path); 61 | var args = new string[Parameters.Length]; 62 | for (int i = 0; i < Parameters.Length; i++) 63 | { 64 | var parameterName = Parameters[i]; 65 | args[i] = Uri.UnescapeDataString(match.Groups[parameterName].Value); 66 | } 67 | var controller = (IController)Activator.CreateInstance(ControllerType); 68 | controller.Request = req; 69 | controller.Response = res; 70 | controller.Context = context; 71 | var typedController = Convert.ChangeType(controller, ControllerType); 72 | var typedArgs = new object[args.Length + 1]; 73 | typedArgs[0] = next; 74 | for (int i = 0; i < Parameters.Length; i++) 75 | { 76 | var paramKey = Parameters[i]; 77 | var arg = args[i]; 78 | var parameter = HandlerParameters[paramKey]; 79 | typedArgs[i + 1] = Convert.ChangeType(arg, parameter.ParameterType); 80 | } 81 | HandlerInfo.Invoke(typedController, typedArgs); 82 | } 83 | return isMatch; 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /ALE.Http/ListenerResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.IO; 4 | using System.Net; 5 | using System.Text; 6 | using ALE.Views; 7 | 8 | namespace ALE.Http 9 | { 10 | public class ListenerResponse : IResponse 11 | { 12 | protected readonly HttpListenerResponse InnerResponse; 13 | 14 | public IViewProcessor ViewProcessor { get; set; } 15 | 16 | internal ListenerResponse(HttpListenerResponse innerResponse, IContext context) 17 | { 18 | if (innerResponse == null) throw new ArgumentNullException("innerResponse"); 19 | if (context == null) throw new ArgumentNullException("context"); 20 | InnerResponse = innerResponse; 21 | Context = context; 22 | ContentType = "text/html"; 23 | ContentEncoding = Encoding.UTF8; 24 | } 25 | 26 | public bool Closed { get; private set; } 27 | 28 | public bool KeepAlive 29 | { 30 | get { return InnerResponse.KeepAlive; } 31 | set { InnerResponse.KeepAlive = value; } 32 | } 33 | 34 | public Version ProtocalVersion 35 | { 36 | get { return InnerResponse.ProtocolVersion; } 37 | set { InnerResponse.ProtocolVersion = value; } 38 | } 39 | 40 | public bool SendChunked 41 | { 42 | get { return InnerResponse.SendChunked; } 43 | set { InnerResponse.SendChunked = value; } 44 | } 45 | 46 | public IContext Context { get; private set; } 47 | 48 | public string ContentType 49 | { 50 | get { return InnerResponse.ContentType; } 51 | set { InnerResponse.ContentType = value; } 52 | } 53 | 54 | public Encoding ContentEncoding 55 | { 56 | get { return InnerResponse.ContentEncoding; } 57 | set { InnerResponse.ContentEncoding = value; } 58 | } 59 | 60 | public Stream OutputStream 61 | { 62 | get { return InnerResponse.OutputStream; } 63 | } 64 | 65 | public IResponse Write(string text) 66 | { 67 | // Construct a response. 68 | var buffer = ContentEncoding.GetBytes(text); 69 | return Write(buffer); 70 | } 71 | 72 | public IResponse Write(byte[] binary) 73 | { 74 | OutputStream.Write(binary, 0, binary.Length); 75 | return this; 76 | } 77 | 78 | public IResponse Render(string view, object model, Action callback) 79 | { 80 | if (callback == null) throw new ArgumentNullException("callback"); 81 | if (ViewProcessor == null) 82 | { 83 | throw new InvalidOperationException("ViewProcessor is null, unable to process view."); 84 | } 85 | ViewProcessor.Render(view, model, (ex, rendered) => 86 | { 87 | Write(rendered); 88 | callback(ex); 89 | }); 90 | return this; 91 | } 92 | 93 | public void Send() 94 | { 95 | OutputStream.Flush(); 96 | OutputStream.Close(); 97 | } 98 | 99 | public CookieCollection Cookies 100 | { 101 | get { return InnerResponse.Cookies; } 102 | } 103 | 104 | public NameValueCollection Headers 105 | { 106 | get { return InnerResponse.Headers; } 107 | } 108 | 109 | public string RedirectLocation 110 | { 111 | get { return InnerResponse.RedirectLocation; } 112 | set { InnerResponse.RedirectLocation = value; } 113 | } 114 | 115 | public int StatusCode 116 | { 117 | get { return InnerResponse.StatusCode; } 118 | set { InnerResponse.StatusCode = value; } 119 | } 120 | 121 | public string StatusDescription 122 | { 123 | get { return InnerResponse.StatusDescription; } 124 | set { InnerResponse.StatusDescription = value; } 125 | } 126 | 127 | public void AddHeader(string name, string value) 128 | { 129 | InnerResponse.AddHeader(name, value); 130 | } 131 | 132 | public void AppendCookie(Cookie cookie) 133 | { 134 | InnerResponse.AppendCookie(cookie); 135 | } 136 | 137 | public void AppendHeader(string name, string value) 138 | { 139 | InnerResponse.AppendHeader(name, value); 140 | } 141 | 142 | public void Redirect(string url) 143 | { 144 | InnerResponse.Redirect(url); 145 | } 146 | } 147 | } -------------------------------------------------------------------------------- /ALE/Do.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using System.Threading; 4 | 5 | namespace ALE 6 | { 7 | public class Do 8 | { 9 | public static void Async(Action operation, Action callback = null) 10 | { 11 | EventLoop.Pend(() => 12 | { 13 | try 14 | { 15 | operation(); 16 | if (callback != null) 17 | { 18 | EventLoop.Pend(() => callback(null)); 19 | } 20 | } catch (Exception ex) 21 | { 22 | if (callback != null) 23 | { 24 | EventLoop.Pend(() => callback(ex)); 25 | } 26 | } 27 | }); 28 | } 29 | 30 | public static void Async(Func operation, Action callback) 31 | { 32 | EventLoop.Pend(() => 33 | { 34 | try 35 | { 36 | var result = operation(); 37 | callback(null, result); 38 | } catch (Exception ex) 39 | { 40 | EventLoop.Pend(() => callback(ex, default(TReturn))); 41 | throw; 42 | } 43 | }); 44 | } 45 | 46 | public static IAsyncKillswitch Timeout(Action operation, int milliseconds) 47 | { 48 | var wait = new AutoResetEvent(false); 49 | var regWait =ThreadPool.RegisterWaitForSingleObject(wait, 50 | (st, to) => operation(), 51 | null, 52 | TimeSpan.FromMilliseconds(milliseconds), 53 | true); 54 | return new TimeoutKillswitch(regWait, wait); 55 | } 56 | 57 | public static IAsyncKillswitch Interval(Action operation, int milliseconds) 58 | { 59 | var timer = new Timer(st => operation(), null, milliseconds, milliseconds); 60 | return new IntervalKillswitch(timer); 61 | } 62 | } 63 | 64 | internal class IntervalKillswitch : IAsyncKillswitch, IDisposable 65 | { 66 | public readonly Timer Timer; 67 | 68 | public IntervalKillswitch(Timer timer) 69 | { 70 | Timer = timer; 71 | } 72 | 73 | public void Kill() 74 | { 75 | Dispose(); 76 | } 77 | 78 | ~IntervalKillswitch() 79 | { 80 | Dispose(); 81 | } 82 | 83 | public void Dispose() 84 | { 85 | if (Timer != null) 86 | { 87 | Timer.Dispose(); 88 | } 89 | } 90 | } 91 | internal class TimeoutKillswitch : IAsyncKillswitch 92 | { 93 | public readonly RegisteredWaitHandle RegisteredWaitHandle; 94 | public readonly WaitHandle WaitHandle; 95 | 96 | public TimeoutKillswitch(RegisteredWaitHandle regWait, WaitHandle wait) 97 | { 98 | RegisteredWaitHandle = regWait; 99 | WaitHandle = wait; 100 | } 101 | public void Kill() 102 | { 103 | RegisteredWaitHandle.Unregister(WaitHandle); 104 | } 105 | } 106 | public interface IAsyncKillswitch 107 | { 108 | void Kill(); 109 | } 110 | } -------------------------------------------------------------------------------- /ALE.Sql/Sql.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Data; 3 | using System.Data.SqlClient; 4 | using System.Reflection; 5 | 6 | namespace ALE.Sql 7 | { 8 | public class Sql : IDisposable 9 | { 10 | protected readonly SqlConnection Connection; 11 | protected readonly string ConnectionString; 12 | 13 | private Sql(string connectionString) 14 | { 15 | ConnectionString = connectionString; 16 | Connection = new SqlConnection(ConnectionString); 17 | } 18 | 19 | #region IDisposable Members 20 | 21 | public void Dispose() 22 | { 23 | if (Connection != null) 24 | { 25 | Connection.Dispose(); 26 | } 27 | } 28 | 29 | #endregion 30 | 31 | public static Sql Create(string connectionString) 32 | { 33 | return new Sql(connectionString); 34 | } 35 | 36 | private SqlParameter[] ConvertObjectToSqlParams(object args) 37 | { 38 | var properties = args.GetType().GetProperties(BindingFlags.Public | BindingFlags.GetField); 39 | var parameters = new SqlParameter[properties.Length]; 40 | for (var i = 0; i < properties.Length; i++) 41 | { 42 | var property = properties[i]; 43 | parameters[i] = new SqlParameter(property.Name, property.GetValue(args, null)); 44 | } 45 | return parameters; 46 | } 47 | 48 | public SqlCommand CreateCommand(string commandText, object args = null, CommandType commandType = CommandType.Text) 49 | { 50 | var cmd = new SqlCommand(commandText, Connection); 51 | cmd.CommandType = commandType; 52 | if (args != null) 53 | { 54 | cmd.Parameters.AddRange(ConvertObjectToSqlParams(args)); 55 | } 56 | return cmd; 57 | } 58 | 59 | public Sql ExecuteReader(string commandText, Action callback) 60 | { 61 | return ExecuteReader(commandText, null, callback); 62 | } 63 | 64 | public Sql ExecuteReader(string commandText, object args, Action callback) 65 | { 66 | return ExecuteReader(commandText, args, CommandType.Text, callback); 67 | } 68 | 69 | public Sql ExecuteReader(string commandText, object args, CommandType cmdType, Action callback) 70 | { 71 | var cmd = CreateCommand(commandText, args, cmdType); 72 | return ExecuteReader(cmd, callback); 73 | } 74 | 75 | public Sql ExecuteReader(SqlCommand cmd, Action callback) 76 | { 77 | if (callback == null) throw new ArgumentNullException("callback"); 78 | cmd.Connection.Open(); 79 | var state = new ExecuteReaderState(cmd, callback); 80 | cmd.BeginExecuteReader(EndExecuteReader, state); 81 | return this; 82 | } 83 | 84 | private void EndExecuteReader(IAsyncResult result) 85 | { 86 | var state = (ExecuteReaderState)result.AsyncState; 87 | try 88 | { 89 | var reader = state.Command.EndExecuteReader(result); 90 | EventLoop.Pend(() => state.Callback(null, reader)); 91 | } catch (Exception ex) 92 | { 93 | EventLoop.Pend(() => state.Callback(ex, null)); 94 | } 95 | } 96 | 97 | public Sql ExecuteNonQuery(string commandText, Action callback = null) 98 | { 99 | return this.ExecuteNonQuery(commandText, null, callback); 100 | } 101 | 102 | public Sql ExecuteNonQuery(string commandText, object args, Action callback = null) 103 | { 104 | return ExecuteNonQuery(commandText, args, CommandType.Text); 105 | } 106 | 107 | public Sql ExecuteNonQuery(string commandText, object args, CommandType commandType, Action callback = null) 108 | { 109 | var cmd = CreateCommand(commandText, args, commandType); 110 | return ExecuteNonQuery(cmd, callback); 111 | } 112 | 113 | public Sql ExecuteNonQuery(SqlCommand cmd, Action callback = null) 114 | { 115 | cmd.Connection.Open(); 116 | var state = new ExecuteNonQueryState(cmd, callback); 117 | cmd.BeginExecuteNonQuery(ExecuteNonQueryCallback, state); 118 | return this; 119 | } 120 | 121 | public void ExecuteNonQueryCallback(IAsyncResult result) 122 | { 123 | var state = (ExecuteNonQueryState) result.AsyncState; 124 | try 125 | { 126 | var recordsAffected = state.Command.EndExecuteNonQuery(result); 127 | EventLoop.Pend(() => state.Callback(null, recordsAffected)); 128 | } catch (Exception ex) 129 | { 130 | EventLoop.Pend(() => state.Callback(ex, -1)); 131 | } 132 | } 133 | } 134 | 135 | public class ExecuteNonQueryState 136 | { 137 | public readonly SqlCommand Command; 138 | public readonly Action Callback; 139 | 140 | public ExecuteNonQueryState(SqlCommand cmd, Action callback) 141 | { 142 | Command = cmd; 143 | Callback = callback; 144 | } 145 | } 146 | 147 | public class ExecuteReaderState 148 | { 149 | public readonly SqlCommand Command; 150 | public readonly Action Callback; 151 | 152 | public ExecuteReaderState(SqlCommand cmd, Action callback) 153 | { 154 | Command = cmd; 155 | Callback = callback; 156 | } 157 | } 158 | } -------------------------------------------------------------------------------- /Backup/AleIISTest/AleIISTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 7 | 8 | 2.0 9 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266} 10 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 11 | Library 12 | Properties 13 | AleIISTest 14 | AleIISTest 15 | v4.0 16 | false 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | Designer 57 | 58 | 59 | Web.config 60 | 61 | 62 | Web.config 63 | 64 | 65 | 66 | 67 | Global.asax 68 | 69 | 70 | 71 | 72 | 73 | {3CB804B8-474A-4399-8E69-12EBB533CBEC} 74 | ALE.Http 75 | 76 | 77 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B} 78 | ALE.Web 79 | 80 | 81 | {48CE219E-2D15-46D8-889F-52E04D110097} 82 | ALE 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | False 92 | True 93 | 58025 94 | / 95 | 96 | 97 | False 98 | True 99 | http://localhost:1338 100 | False 101 | 102 | 103 | 104 | 105 | 112 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **ALE - Another Looping Event - (Alpha)** 2 | 3 | Created by Ben Lesh 4 | http://www.benlesh.com 5 | ben@benlesh.com 6 | 7 | Licensed under MIT license 8 | 9 | === 10 | # DO NOT USE: This is an old experiment and is not maintained 11 | 12 | This project is a Node.js style implementation of an event loop architecture in C#. This is something I whipped up for fun, mostly as a proof of concept. I like it though, and I'm looking for feedback. 13 | 14 | Thank you for any feedback you might have. 15 | 16 | *examples* 17 | 18 | To start a webserver: 19 | 20 | ```CSharp 21 | EventLoop.Start(() => { 22 | Server.Create() 23 | .Use((req, res) => { 24 | res.Write("

Hello World

"); 25 | }).Listen("http://*:1337"); 26 | }); 27 | ``` 28 | 29 | To set up a web sockets server: 30 | 31 | ```CSharp 32 | EventLoop.Start(() => { 33 | Net.CreateServer((socket) => { 34 | socket.Receive((text) => { 35 | socket.Send("Echo: " + text); 36 | }); 37 | }).Listen("127.0.0.1", 1338, "http://origin.com"); 38 | }); 39 | ``` 40 | 41 | Or just to do something like read a file from disk: 42 | 43 | ```CSharp 44 | EventLoop.Start(() => { 45 | File.ReadAllText(@"C:\File.txt", (text) => { 46 | DoSomething(text); 47 | }); 48 | }); 49 | ``` 50 | 51 | To start a ALE in IIS: 52 | 53 | * Start a new web project. 54 | * Reference ALE and ALE.Web. 55 | * Add a reference to the HttpHandler in the Web.Config (here is the minimum Web.config required): 56 | 57 | ```xml 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 70 | 71 | 72 | 73 | ``` 74 | 75 | 76 | * Add initialization code to Application_Start in your Global.asax: 77 | ```CSharp 78 | void Application_Start(object sender, EventArgs e) 79 | { 80 | // Start the event loop. 81 | EventLoop.Start(); 82 | 83 | // Get the ALE server instance and wire up your middlware. 84 | ALE.Web.Server.Create() 85 | .Use((req, res) => res.Write("Hello World")) 86 | .Use((req, res) => res.Write("
No seriously, I said hello.")); 87 | } 88 | ``` 89 | * Add teardown in Application_End in your Global.asax: 90 | ``` 91 | void Application_End(object sender, EventArgs e) 92 | { 93 | // Shut down the EventLoop. 94 | EventLoop.Stop(); 95 | } 96 | ``` 97 | 98 | 99 | See my related blog posts for more information: http://www.benlesh.com/search/label/ALE 100 | 101 | Version History 102 | * v 0.0.10.2 - Added basic Promise implementation 103 | * v 0.0.9.4 - Updated EventLoops to be slightly more efficient. 104 | * added unit tests. 105 | * Fixed issues with Razor templating. 106 | * Fixed some issues with routing. 107 | * v 0.0.7.2 - Added FileSystemWatcher implemention. 108 | * added beginnings of Razor template view processor. 109 | * v 0.0.7.0 - Added routing. 110 | * v 0.0.6.1 - Rewrote EventLoop to use Tasks and ContinueWith rather than Actions for performance reasons, and cleaned up the api a little. 111 | * moved File class to proper namespace. 112 | * updated File async methods. 113 | * added File.Read method for streaming file data. 114 | * v 0.0.5.0 - Added asynchronous http handler for IIS integration. 115 | * v 0.0.4.6 - Added a static file server implementation. 116 | * v 0.0.4.4 - Updated web server to use a single event to register all actions 117 | * removed preprocessor and post processor events. 118 | * Create method no longer used to register a main event. There is no main event. 119 | * v 0.0.4.2 - Converted middleware usage to simple event/delegate implementation. 120 | * v 0.0.4.1 - Abstractions and Middleware capabilities added. Laying the groundwork for a routed server. 121 | * Abstracted out Server, Request and Response. 122 | * Added IPreprocessor and IPostprocessor for "before and after" middleware implementations. 123 | * Added Using method and overloards to IServer to handle attaching middleware. 124 | * v 0.0.3.0 - Added non-blocking WebSocket implementation 125 | * v 0.0.2.2 - Fixed a few issues 126 | * Fixed an issue where EventLoop wouldn't pause when Events Queue was empty. 127 | * Added Do.Async functionality. 128 | * Tested multithreaded event-loop processing. 129 | * v 0.0.2.1 - Updated Sql client Reader call to .NET's non-blocking async call. 130 | * v 0.0.2.0 - Updated all I/O called to .NET's non-blocking async calls. 131 | * v 0.0.1.0 - Added a simple SqlClient implementation, ExecuteReader only for now. More soon. 132 | -------------------------------------------------------------------------------- /ALE.Http/Server.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net; 4 | using ALE.Views; 5 | using System.Collections.Generic; 6 | 7 | namespace ALE.Http 8 | { 9 | /// 10 | /// A simple asynchronous web server for ALE. 11 | /// 12 | public class Server : ServerBase 13 | { 14 | /// 15 | /// The HTTP listener that handles receiving requests. 16 | /// 17 | protected readonly HttpListener Listener; 18 | 19 | /// 20 | /// Creates a new instance of a server. 21 | /// 22 | /// The request received delegate. 23 | private Server() 24 | { 25 | Listener = new HttpListener(); 26 | } 27 | 28 | /// 29 | /// Starts the server listening an any number of URI prefixes. 30 | /// 31 | /// URI prefixes for the server to listen on. 32 | /// The server it started. 33 | public Server Listen(params string[] prefixes) 34 | { 35 | if (Process == null) 36 | throw new InvalidOperationException("Cannot run a server with no callback. Process event must be set."); 37 | foreach (var prefix in prefixes) 38 | { 39 | Listener.Prefixes.Add(prefix); 40 | } 41 | if (!Listener.IsListening) 42 | { 43 | Listener.Start(); 44 | Listener.BeginGetContext(GetContextCallback, Listener); 45 | } 46 | return this; 47 | } 48 | 49 | /// 50 | /// Async callback for GetContextCallBack in Listen method above. 51 | /// 52 | /// The IAsyncResult. 53 | private void GetContextCallback(IAsyncResult result) 54 | { 55 | var listener = (HttpListener)result.AsyncState; 56 | var resultContext = listener.EndGetContext(result); 57 | 58 | var context = new ListenerContext(resultContext); 59 | EventLoop.Pend(() => 60 | { 61 | if (ViewProcessor != null) 62 | { 63 | context.Response.ViewProcessor = ViewProcessor; 64 | } 65 | OnProcess(context); 66 | }); 67 | listener.BeginGetContext(GetContextCallback, listener); 68 | } 69 | 70 | /// 71 | /// Stop the server. 72 | /// 73 | /// 74 | public void Stop(bool stopEventLoop = false) 75 | { 76 | Listener.Stop(); 77 | if (stopEventLoop) 78 | { 79 | EventLoop.Stop(); 80 | } 81 | } 82 | 83 | public new Server Use(Action processor) 84 | { 85 | return (Server)base.Use(processor); 86 | } 87 | 88 | public new Server Use(IViewProcessor viewProcessor) 89 | { 90 | return (Server)base.Use(viewProcessor); 91 | } 92 | 93 | public static Server Create() 94 | { 95 | return new Server(); 96 | } 97 | } 98 | 99 | public abstract class ServerBase 100 | { 101 | 102 | /// 103 | /// Sets the type of view processor to use. 104 | /// 105 | /// The view processor to use. 106 | /// The server instance. 107 | public ServerBase Use(IViewProcessor viewProcessor) 108 | { 109 | ViewProcessor = viewProcessor; 110 | return this; 111 | } 112 | 113 | /// 114 | /// The view processor requests will use. 115 | /// 116 | protected IViewProcessor ViewProcessor; 117 | 118 | /// 119 | /// Adds preprocessing middleware. 120 | /// 121 | /// The middleware to add. 122 | /// 123 | /// The server instance. 124 | public ServerBase Use(Action processor) 125 | { 126 | Process.Add(processor); 127 | return this; 128 | } 129 | 130 | public readonly List> Process = new List>(); 131 | 132 | protected void OnProcess(IContext context) 133 | { 134 | var processQueue = new Queue>(Process); 135 | Action next = null; 136 | next = () => 137 | { 138 | if (processQueue.Count > 0) 139 | { 140 | var nextProcessor = processQueue.Dequeue(); 141 | if (nextProcessor != null) 142 | { 143 | nextProcessor(context, next); 144 | } 145 | } else 146 | { 147 | context.Response.Send(); 148 | } 149 | }; 150 | next(); 151 | } 152 | } 153 | } -------------------------------------------------------------------------------- /ALE.Tests/EventLoop_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 System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace ALE.Tests 10 | { 11 | [TestClass] 12 | public class EventLoop_Tests 13 | { 14 | [TestMethod] 15 | public void EventLoop_Start() 16 | { 17 | var wait = new AutoResetEvent(false); 18 | EventLoop.Start(() => wait.Set()); 19 | if (wait.WaitOne(100)) 20 | { 21 | Assert.AreEqual(1, EventLoop.WorkerCount); 22 | Assert.IsTrue(EventLoop.IsRunning); 23 | } else 24 | { 25 | Assert.Fail("Did not fire initial event."); 26 | } 27 | } 28 | 29 | [TestMethod] 30 | public void EventLoop_Stop() 31 | { 32 | var wait = new AutoResetEvent(false); 33 | EventLoop.Start(); 34 | const int loops = 10; 35 | for (int i = 0; i < loops; i++) 36 | { 37 | var x = i; 38 | EventLoop.Pend(() => 39 | { 40 | Thread.Sleep(100); 41 | if (x == loops - 1) 42 | { 43 | wait.Set(); 44 | } 45 | }); 46 | 47 | } 48 | EventLoop.Stop(); 49 | if (wait.WaitOne(1200)) 50 | { 51 | Assert.Fail("EventLoop did not stop."); 52 | } 53 | } 54 | 55 | [TestMethod] 56 | public void EventLoop_Pend() 57 | { 58 | var wait = new AutoResetEvent(false); 59 | EventLoop.Start(); 60 | EventLoop.Pend(() => 61 | { 62 | wait.Set(); 63 | }); 64 | if (!wait.WaitOne(100)) 65 | { 66 | Assert.Fail("Event did not fire correctly."); 67 | } 68 | } 69 | 70 | [TestMethod] 71 | public void EventLoop_IsRunning_Property() 72 | { 73 | EventLoop.Start(); 74 | Assert.IsTrue(EventLoop.IsRunning); 75 | EventLoop.Stop(); 76 | Assert.IsFalse(EventLoop.IsRunning); 77 | } 78 | 79 | [TestMethod] 80 | public void EventLoop_IdleWorkerCount() 81 | { 82 | EventLoop.Start(); 83 | Thread.Sleep(10); 84 | Assert.AreEqual(1, EventLoop.IdleWorkerCount); 85 | EventLoop.Pend(() => Thread.Sleep(100)); 86 | Thread.Sleep(10); 87 | Assert.AreEqual(0, EventLoop.IdleWorkerCount); 88 | EventLoop.Stop(); 89 | } 90 | 91 | //[TestMethod] 92 | //public void ContinuationTask_Idle_Check() 93 | //{ 94 | // var wait = new AutoResetEvent(false); 95 | // var task1 = Task.Factory.StartNew(() => 96 | // { 97 | // Thread.Sleep(100); 98 | // }); 99 | // var task2 = task1.ContinueWith(t1 => 100 | // { 101 | // Assert.IsTrue(t1.IsCompleted); 102 | // t1.Dispose(); 103 | // wait.Set(); 104 | // }); 105 | // Assert.IsFalse(task2.IsCompleted); 106 | // wait.WaitOne(200); 107 | // Assert.IsTrue(task2.IsCompleted); 108 | //} 109 | //[TestMethod] 110 | //public void TaskChaining() 111 | //{ 112 | // var actions = new Queue(); 113 | // for (int i = 0; i < 1000; i++) 114 | // { 115 | // actions.Enqueue(() => { }); 116 | // } 117 | // Task worker = Task.Factory.StartNew(() => { }); 118 | // Func getNext = () => actions.Count > 0 ? actions.Dequeue() : null; 119 | // Action work = null; 120 | // work = (inboundTask) => 121 | // { 122 | // Assert.AreEqual(worker, inboundTask); 123 | // var next = getNext(); 124 | // if (next != null) 125 | // { 126 | // worker = inboundTask.ContinueWith(t => 127 | // { 128 | // next(); 129 | // t.Dispose(); 130 | // }); 131 | // worker.ContinueWith(work); 132 | // Assert.AreNotEqual(inboundTask, worker); 133 | // inboundTask.Dispose(); 134 | // } 135 | // }; 136 | // work(worker); 137 | //} 138 | } 139 | } -------------------------------------------------------------------------------- /AleIISTest/AleIISTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | AleIISTest 15 | AleIISTest 16 | v4.0 17 | false 18 | 19 | 20 | 21 | 22 | 4.0 23 | 24 | 25 | true 26 | full 27 | false 28 | bin\ 29 | DEBUG;TRACE 30 | prompt 31 | 4 32 | 33 | 34 | pdbonly 35 | true 36 | bin\ 37 | TRACE 38 | prompt 39 | 4 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Designer 63 | 64 | 65 | Web.config 66 | 67 | 68 | Web.config 69 | 70 | 71 | 72 | 73 | Global.asax 74 | 75 | 76 | 77 | 78 | 79 | {3CB804B8-474A-4399-8E69-12EBB533CBEC} 80 | ALE.Http 81 | 82 | 83 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B} 84 | ALE.Web 85 | 86 | 87 | {48CE219E-2D15-46D8-889F-52E04D110097} 88 | ALE 89 | 90 | 91 | 92 | 10.0 93 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | False 103 | True 104 | 58025 105 | / 106 | 107 | 108 | False 109 | True 110 | http://localhost:1338 111 | False 112 | 113 | 114 | 115 | 116 | 123 | -------------------------------------------------------------------------------- /ALE/FileSystem/File.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Runtime.InteropServices; 7 | 8 | namespace ALE.FileSystem 9 | { 10 | public class File 11 | { 12 | public const int DefaultBufferSize = 65536; //64KB 13 | 14 | /// 15 | /// Reads a file as a stream in chunks. 16 | /// 17 | /// The file path. 18 | /// Called when a chunk is read. 19 | public static void Read(string path, Action callback) 20 | { 21 | var fs = System.IO.File.OpenRead(path); 22 | var buffer = new byte[DefaultBufferSize]; 23 | var state = new ReadAsyncCallbackState(fs, buffer, callback); 24 | fs.BeginRead(buffer, 0, buffer.Length, ReadAsyncCallback, state); 25 | } 26 | 27 | static void ReadAsyncCallback(IAsyncResult result) 28 | { 29 | var state = (ReadAsyncCallbackState)result.AsyncState; 30 | var bytesRead = state.FileStream.EndRead(result); 31 | if (bytesRead > 0) 32 | { 33 | Interlocked.Add(ref state.RemainingBytes, -1*bytesRead); 34 | var buffer = new byte[bytesRead]; 35 | Array.Copy(state.Buffer, buffer, bytesRead); 36 | var callback = state.Callback; 37 | var remainingBytes = state.RemainingBytes; 38 | EventLoop.Pend(() => 39 | { 40 | callback(null, remainingBytes, buffer); 41 | }); 42 | } 43 | } 44 | 45 | public static void ReadAllBytes(string path, Action callback) 46 | { 47 | if (callback == null) throw new ArgumentNullException("callback"); 48 | FileReadAllAsync(path, (ex, buffer) => EventLoop.Pend(() => callback(ex, buffer))); 49 | } 50 | 51 | public static void ReadAllText(string path, Action callback) 52 | { 53 | ReadAllText(path, Encoding.UTF8, callback); 54 | } 55 | 56 | public static void ReadAllText(string path, Encoding encoding, Action callback) 57 | { 58 | if (callback == null) throw new ArgumentNullException("callback"); 59 | if (encoding == null) throw new ArgumentNullException("encoding"); 60 | FileReadAllAsync(path, (ex, buffer) => 61 | { 62 | try 63 | { 64 | if (ex != null) throw ex; 65 | var text = encoding.GetString(buffer); 66 | EventLoop.Pend(() => callback(null, text)); 67 | } catch (Exception ex2) 68 | { 69 | EventLoop.Pend(() => callback(ex2, null)); 70 | } 71 | }); 72 | } 73 | 74 | public static void ReadAllLines(string path, Action callback) 75 | { 76 | ReadAllLines(path, Encoding.UTF8, callback); 77 | } 78 | 79 | public static void ReadAllLines(string path, Encoding encoding, Action callback) 80 | { 81 | if (callback == null) throw new ArgumentNullException("callback"); 82 | if (encoding == null) throw new ArgumentNullException("encoding"); 83 | FileReadAllAsync(path, (ex, buffer) => 84 | { 85 | try 86 | { 87 | if (ex != null) 88 | { 89 | throw ex; 90 | } 91 | var lines = new List(); 92 | using (var ms = new MemoryStream(buffer)) 93 | using (var reader = new StreamReader(ms)) 94 | { 95 | while (reader.Peek() >= 0) 96 | { 97 | lines.Add(reader.ReadLine()); 98 | } 99 | } 100 | EventLoop.Pend(() => callback(null, lines.ToArray())); 101 | } catch (Exception ex2) 102 | { 103 | EventLoop.Pend(() => callback(ex2, null)); 104 | } 105 | }); 106 | } 107 | 108 | private static void FileReadAllAsync(string path, Action complete) 109 | { 110 | try 111 | { 112 | var fs = System.IO.File.OpenRead(path); 113 | var buffer = new byte[fs.Length]; 114 | var state = new AsyncFileReadState(complete, fs, buffer); 115 | fs.BeginRead(buffer, 0, buffer.Length, FileReadAllCallback, state); 116 | } catch (Exception ex) 117 | { 118 | EventLoop.Pend(() => complete(ex, null)); 119 | } 120 | } 121 | 122 | private static void FileReadAllCallback(IAsyncResult result) 123 | { 124 | var state = (AsyncFileReadState)result.AsyncState; 125 | state.FileStream.EndRead(result); 126 | state.Callback(null, state.Buffer); 127 | } 128 | } 129 | } -------------------------------------------------------------------------------- /ALE.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FDD27A3F-ED59-4239-AC68-0EA80B1F91B2}" 5 | ProjectSection(SolutionItems) = preProject 6 | ALE.vsmdi = ALE.vsmdi 7 | license.txt = license.txt 8 | Local.testsettings = Local.testsettings 9 | README.md = README.md 10 | TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings 11 | EndProjectSection 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE", "ALE\ALE.csproj", "{48CE219E-2D15-46D8-889F-52E04D110097}" 14 | EndProject 15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Tests", "ALE.Tests\ALE.Tests.csproj", "{C0DCF894-5025-44A9-BCF2-1FD803EC3A10}" 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.ConsoleTest", "ALE.ConsoleTest\ALE.ConsoleTest.csproj", "{7AEA9929-B496-425F-8F80-DE270504940A}" 18 | EndProject 19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AleIISTest", "AleIISTest\AleIISTest.csproj", "{8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}" 20 | EndProject 21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Web", "ALE.Web\ALE.Web.csproj", "{799DEAB2-BC16-4EDA-93F7-C0214E4D355B}" 22 | EndProject 23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Http", "ALE.Http\ALE.Http.csproj", "{3CB804B8-474A-4399-8E69-12EBB533CBEC}" 24 | EndProject 25 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Views.Razor", "ALE.Views.Razor\ALE.Views.Razor.csproj", "{36A64DC1-B883-49DC-BDB8-21FDC8987D0B}" 26 | EndProject 27 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Sql", "ALE.Sql\ALE.Sql.csproj", "{54C95345-6D76-485F-927E-6B5C78DBE639}" 28 | EndProject 29 | Global 30 | GlobalSection(TestCaseManagementSettings) = postSolution 31 | CategoryFile = ALE.vsmdi 32 | EndGlobalSection 33 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 34 | Debug|Any CPU = Debug|Any CPU 35 | Debug|Mixed Platforms = Debug|Mixed Platforms 36 | Debug|x86 = Debug|x86 37 | Release|Any CPU = Release|Any CPU 38 | Release|Mixed Platforms = Release|Mixed Platforms 39 | Release|x86 = Release|x86 40 | EndGlobalSection 41 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 42 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 45 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 46 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|x86.ActiveCfg = Debug|Any CPU 47 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|Any CPU.ActiveCfg = Release|Any CPU 48 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|Any CPU.Build.0 = Release|Any CPU 49 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 50 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|Mixed Platforms.Build.0 = Release|Any CPU 51 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|x86.ActiveCfg = Release|Any CPU 52 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 55 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 56 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|x86.ActiveCfg = Debug|Any CPU 57 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|Any CPU.ActiveCfg = Release|Any CPU 58 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|Any CPU.Build.0 = Release|Any CPU 59 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 60 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|Mixed Platforms.Build.0 = Release|Any CPU 61 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|x86.ActiveCfg = Release|Any CPU 62 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|Any CPU.ActiveCfg = Debug|x86 63 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 64 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|Mixed Platforms.Build.0 = Debug|x86 65 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|x86.ActiveCfg = Debug|x86 66 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|x86.Build.0 = Debug|x86 67 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|Any CPU.ActiveCfg = Release|x86 68 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|Mixed Platforms.ActiveCfg = Release|x86 69 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|Mixed Platforms.Build.0 = Release|x86 70 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|x86.ActiveCfg = Release|x86 71 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|x86.Build.0 = Release|x86 72 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 73 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|Any CPU.Build.0 = Debug|Any CPU 74 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 75 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 76 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|x86.ActiveCfg = Debug|Any CPU 77 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|Any CPU.ActiveCfg = Release|Any CPU 78 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|Any CPU.Build.0 = Release|Any CPU 79 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 80 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|Mixed Platforms.Build.0 = Release|Any CPU 81 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|x86.ActiveCfg = Release|Any CPU 82 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 83 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|Any CPU.Build.0 = Debug|Any CPU 84 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 85 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 86 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|x86.ActiveCfg = Debug|Any CPU 87 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|Any CPU.ActiveCfg = Release|Any CPU 88 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|Any CPU.Build.0 = Release|Any CPU 89 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 90 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|Mixed Platforms.Build.0 = Release|Any CPU 91 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|x86.ActiveCfg = Release|Any CPU 92 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 93 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|Any CPU.Build.0 = Debug|Any CPU 94 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 95 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 96 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|x86.ActiveCfg = Debug|Any CPU 97 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|Any CPU.ActiveCfg = Release|Any CPU 98 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|Any CPU.Build.0 = Release|Any CPU 99 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 100 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|Mixed Platforms.Build.0 = Release|Any CPU 101 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|x86.ActiveCfg = Release|Any CPU 102 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 103 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|Any CPU.Build.0 = Debug|Any CPU 104 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 105 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 106 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|x86.ActiveCfg = Debug|Any CPU 107 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|Any CPU.ActiveCfg = Release|Any CPU 108 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|Any CPU.Build.0 = Release|Any CPU 109 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 110 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|Mixed Platforms.Build.0 = Release|Any CPU 111 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|x86.ActiveCfg = Release|Any CPU 112 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 113 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|Any CPU.Build.0 = Debug|Any CPU 114 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 115 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 116 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|x86.ActiveCfg = Debug|Any CPU 117 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|Any CPU.ActiveCfg = Release|Any CPU 118 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|Any CPU.Build.0 = Release|Any CPU 119 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 120 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|Mixed Platforms.Build.0 = Release|Any CPU 121 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|x86.ActiveCfg = Release|Any CPU 122 | EndGlobalSection 123 | GlobalSection(SolutionProperties) = preSolution 124 | HideSolutionNode = FALSE 125 | EndGlobalSection 126 | EndGlobal 127 | -------------------------------------------------------------------------------- /Backup/ALE.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE", "ALE\ALE.csproj", "{48CE219E-2D15-46D8-889F-52E04D110097}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Tests", "ALE.Tests\ALE.Tests.csproj", "{C0DCF894-5025-44A9-BCF2-1FD803EC3A10}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FDD27A3F-ED59-4239-AC68-0EA80B1F91B2}" 9 | ProjectSection(SolutionItems) = preProject 10 | ALE.vsmdi = ALE.vsmdi 11 | license.txt = license.txt 12 | Local.testsettings = Local.testsettings 13 | README.md = README.md 14 | TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings 15 | EndProjectSection 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.ConsoleTest", "ALE.ConsoleTest\ALE.ConsoleTest.csproj", "{7AEA9929-B496-425F-8F80-DE270504940A}" 18 | EndProject 19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AleIISTest", "AleIISTest\AleIISTest.csproj", "{8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}" 20 | EndProject 21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Web", "ALE.Web\ALE.Web.csproj", "{799DEAB2-BC16-4EDA-93F7-C0214E4D355B}" 22 | EndProject 23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Http", "ALE.Http\ALE.Http.csproj", "{3CB804B8-474A-4399-8E69-12EBB533CBEC}" 24 | EndProject 25 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Views.Razor", "ALE.Views.Razor\ALE.Views.Razor.csproj", "{36A64DC1-B883-49DC-BDB8-21FDC8987D0B}" 26 | EndProject 27 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALE.Sql", "ALE.Sql\ALE.Sql.csproj", "{54C95345-6D76-485F-927E-6B5C78DBE639}" 28 | EndProject 29 | Global 30 | GlobalSection(TestCaseManagementSettings) = postSolution 31 | CategoryFile = ALE.vsmdi 32 | EndGlobalSection 33 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 34 | Debug|Any CPU = Debug|Any CPU 35 | Debug|Mixed Platforms = Debug|Mixed Platforms 36 | Debug|x86 = Debug|x86 37 | Release|Any CPU = Release|Any CPU 38 | Release|Mixed Platforms = Release|Mixed Platforms 39 | Release|x86 = Release|x86 40 | EndGlobalSection 41 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 42 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 45 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 46 | {48CE219E-2D15-46D8-889F-52E04D110097}.Debug|x86.ActiveCfg = Debug|Any CPU 47 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|Any CPU.ActiveCfg = Release|Any CPU 48 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|Any CPU.Build.0 = Release|Any CPU 49 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 50 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|Mixed Platforms.Build.0 = Release|Any CPU 51 | {48CE219E-2D15-46D8-889F-52E04D110097}.Release|x86.ActiveCfg = Release|Any CPU 52 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 55 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 56 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Debug|x86.ActiveCfg = Debug|Any CPU 57 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|Any CPU.ActiveCfg = Release|Any CPU 58 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|Any CPU.Build.0 = Release|Any CPU 59 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 60 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|Mixed Platforms.Build.0 = Release|Any CPU 61 | {C0DCF894-5025-44A9-BCF2-1FD803EC3A10}.Release|x86.ActiveCfg = Release|Any CPU 62 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|Any CPU.ActiveCfg = Debug|x86 63 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 64 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|Mixed Platforms.Build.0 = Debug|x86 65 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|x86.ActiveCfg = Debug|x86 66 | {7AEA9929-B496-425F-8F80-DE270504940A}.Debug|x86.Build.0 = Debug|x86 67 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|Any CPU.ActiveCfg = Release|x86 68 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|Mixed Platforms.ActiveCfg = Release|x86 69 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|Mixed Platforms.Build.0 = Release|x86 70 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|x86.ActiveCfg = Release|x86 71 | {7AEA9929-B496-425F-8F80-DE270504940A}.Release|x86.Build.0 = Release|x86 72 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 73 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|Any CPU.Build.0 = Debug|Any CPU 74 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 75 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 76 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Debug|x86.ActiveCfg = Debug|Any CPU 77 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|Any CPU.ActiveCfg = Release|Any CPU 78 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|Any CPU.Build.0 = Release|Any CPU 79 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 80 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|Mixed Platforms.Build.0 = Release|Any CPU 81 | {8F4D3FC9-5F19-410E-8B26-DAAD61BA6266}.Release|x86.ActiveCfg = Release|Any CPU 82 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 83 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|Any CPU.Build.0 = Debug|Any CPU 84 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 85 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 86 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Debug|x86.ActiveCfg = Debug|Any CPU 87 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|Any CPU.ActiveCfg = Release|Any CPU 88 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|Any CPU.Build.0 = Release|Any CPU 89 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 90 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|Mixed Platforms.Build.0 = Release|Any CPU 91 | {799DEAB2-BC16-4EDA-93F7-C0214E4D355B}.Release|x86.ActiveCfg = Release|Any CPU 92 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 93 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|Any CPU.Build.0 = Debug|Any CPU 94 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 95 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 96 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Debug|x86.ActiveCfg = Debug|Any CPU 97 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|Any CPU.ActiveCfg = Release|Any CPU 98 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|Any CPU.Build.0 = Release|Any CPU 99 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 100 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|Mixed Platforms.Build.0 = Release|Any CPU 101 | {3CB804B8-474A-4399-8E69-12EBB533CBEC}.Release|x86.ActiveCfg = Release|Any CPU 102 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 103 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|Any CPU.Build.0 = Debug|Any CPU 104 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 105 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 106 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Debug|x86.ActiveCfg = Debug|Any CPU 107 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|Any CPU.ActiveCfg = Release|Any CPU 108 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|Any CPU.Build.0 = Release|Any CPU 109 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 110 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|Mixed Platforms.Build.0 = Release|Any CPU 111 | {36A64DC1-B883-49DC-BDB8-21FDC8987D0B}.Release|x86.ActiveCfg = Release|Any CPU 112 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 113 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|Any CPU.Build.0 = Debug|Any CPU 114 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 115 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 116 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Debug|x86.ActiveCfg = Debug|Any CPU 117 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|Any CPU.ActiveCfg = Release|Any CPU 118 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|Any CPU.Build.0 = Release|Any CPU 119 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 120 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|Mixed Platforms.Build.0 = Release|Any CPU 121 | {54C95345-6D76-485F-927E-6B5C78DBE639}.Release|x86.ActiveCfg = Release|Any CPU 122 | EndGlobalSection 123 | GlobalSection(SolutionProperties) = preSolution 124 | HideSolutionNode = FALSE 125 | EndGlobalSection 126 | EndGlobal 127 | -------------------------------------------------------------------------------- /ALE/Tcp/WebSocket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Net.Sockets; 6 | using System.Text; 7 | 8 | namespace ALE.Tcp 9 | { 10 | public class WebSocket 11 | { 12 | public readonly WebSocketServer Server; 13 | private readonly List> _receiveEvents = new List>(); 14 | private readonly TcpClient _tcp; 15 | public string ClientHandshake; 16 | public Encoding Encoding = Encoding.Default; 17 | 18 | public WebSocket(WebSocketServer server, TcpClient tcp) 19 | { 20 | Server = server; 21 | _tcp = tcp; 22 | } 23 | 24 | public void Send(string text, Action callback = null) 25 | { 26 | Debug.WriteLine(text); 27 | byte[] writeBuffer = EncodeServerData(text); 28 | NetworkStream netstream = _tcp.GetStream(); 29 | var state = new SendState(netstream, callback); 30 | netstream.BeginWrite(writeBuffer, 0, writeBuffer.Length, SendCallback, state); 31 | } 32 | 33 | public void SendUnencoded(string text, Action callback = null) 34 | { 35 | byte[] writeBuffer = Encoding.GetBytes(text); 36 | NetworkStream netstream = _tcp.GetStream(); 37 | var state = new SendState(netstream, callback); 38 | netstream.BeginWrite(writeBuffer, 0, writeBuffer.Length, SendCallback, state); 39 | } 40 | 41 | private void SendCallback(IAsyncResult result) 42 | { 43 | var state = (SendState) result.AsyncState; 44 | NetworkStream netstream = state.NetworkStream; 45 | Action callback = state.Callback; 46 | try 47 | { 48 | netstream.EndWrite(result); 49 | if (callback != null) 50 | { 51 | EventLoop.Pend(() => callback(null)); 52 | } 53 | } 54 | catch (Exception ex) 55 | { 56 | EventLoop.Pend(() => callback(ex)); 57 | } 58 | } 59 | 60 | public void Receive(Action callback) 61 | { 62 | _receiveEvents.Add(callback); 63 | } 64 | 65 | internal void BeginRead() 66 | { 67 | NetworkStream netstream = _tcp.GetStream(); 68 | int bufferSize = _tcp.ReceiveBufferSize; 69 | var state = new ReadState(netstream, bufferSize); 70 | netstream.BeginRead(state.Buffer, 0, state.Buffer.Length, ReadCallback, state); 71 | } 72 | 73 | private void ReadCallback(IAsyncResult result) 74 | { 75 | var state = (ReadState) result.AsyncState; 76 | NetworkStream netstream = state.NetworkStream; 77 | int bytesRead = netstream.EndRead(result); 78 | ProcessRead(bytesRead, state); 79 | } 80 | 81 | private void ProcessRead(int bytesRead, ReadState state) 82 | { 83 | if (bytesRead > 0) 84 | { 85 | byte[] buffer = state.Buffer; 86 | if (String.IsNullOrEmpty(ClientHandshake)) 87 | { 88 | SendHandshake(buffer, bytesRead); 89 | } 90 | else 91 | { 92 | ProcessIncoming(buffer, bytesRead); 93 | BeginRead(); 94 | } 95 | } 96 | } 97 | 98 | public void ProcessIncoming(byte[] buffer, int bytesRead) 99 | { 100 | string text = DecodeClientData(buffer.Take(bytesRead).ToArray()); 101 | foreach (var receive in _receiveEvents) 102 | { 103 | Action rec = receive; 104 | EventLoop.Pend(() => rec(text)); 105 | } 106 | } 107 | 108 | private void SendHandshake(byte[] buffer, int bytesRead) 109 | { 110 | string text = Encoding.GetString(buffer, 0, bytesRead); 111 | ClientHandshake = text; 112 | string secKey = WebSocketHandshake.GetSecKey(ClientHandshake); 113 | SendUnencoded(WebSocketHandshake.GetHandshake(Encoding, secKey, Server.IP, Server.Port, Server.Origin), 114 | ex => 115 | { 116 | if (ex != null) 117 | { 118 | EventLoop.Pend(() => Server.Callback(ex, null)); 119 | } 120 | BeginRead(); 121 | EventLoop.Pend(() => Server.Callback(null, this)); 122 | }); 123 | } 124 | 125 | private byte[] EncodeServerData(string text) 126 | { 127 | byte[] bytesRaw = Encoding.GetBytes(text); 128 | byte[] header; 129 | if (bytesRaw.Length <= 125) 130 | { 131 | header = new byte[] 132 | { 133 | 129, 134 | (byte) bytesRaw.Length 135 | }; 136 | } 137 | else if (bytesRaw.Length >= 126 && bytesRaw.Length <= 65535) 138 | { 139 | header = new byte[] 140 | { 141 | 129, 142 | 126, 143 | (byte) ((bytesRaw.Length >> 8) & 255), 144 | (byte) (bytesRaw.Length & 255), 145 | }; 146 | } 147 | else 148 | { 149 | header = new byte[] 150 | { 151 | 129, 152 | 127, 153 | (byte) ((bytesRaw.Length >> 56) & 255), 154 | (byte) ((bytesRaw.Length >> 48) & 255), 155 | (byte) ((bytesRaw.Length >> 40) & 255), 156 | (byte) ((bytesRaw.Length >> 32) & 255), 157 | (byte) ((bytesRaw.Length >> 24) & 255), 158 | (byte) ((bytesRaw.Length >> 16) & 255), 159 | (byte) ((bytesRaw.Length >> 8) & 255), 160 | (byte) (bytesRaw.Length & 255) 161 | }; 162 | } 163 | var result = new byte[header.Length + bytesRaw.Length]; 164 | header.CopyTo(result, 0); 165 | Array.ConstrainedCopy(bytesRaw, 0, result, header.Length, bytesRaw.Length); 166 | return result; 167 | } 168 | 169 | private string DecodeClientData(byte[] bytes) 170 | { 171 | byte secondByte = bytes[1]; 172 | //length = secondByte AND 127 // may not be the actual length in the two special cases 173 | int length = secondByte & 127; 174 | //indexFirstMask = 2 // if not a special case 175 | int indexFirstMask = 2; 176 | //if length == 126 // if a special case, change indexFirstMask 177 | // indexFirstMask = 4 178 | if (length == 126) 179 | { 180 | indexFirstMask = 4; 181 | } 182 | //else if length == 127 // ditto 183 | // indexFirstMask = 10 184 | else if (length == 127) 185 | { 186 | indexFirstMask = 10; 187 | } 188 | //masks = bytes.slice(indexFirstMask, 4) // four bytes starting from indexFirstMask 189 | byte[] masks = bytes.Skip(indexFirstMask).Take(4).ToArray(); 190 | //indexFirstDataByte = indexFirstMask + 4 // four bytes further 191 | int indexFirstDataByte = indexFirstMask + 4; 192 | //decoded = new array 193 | var decoded = new byte[bytes.Length - indexFirstDataByte]; 194 | //decoded.length = bytes.length - indexFirstDataByte // length of real data 195 | 196 | //for i = indexFirstDataByte, j = 0; i < bytes.length; i++, j++ 197 | // decoded[j] = bytes[i] XOR masks[j MOD 4] 198 | for (int i = indexFirstDataByte, j = 0; i < bytes.Length; i++, j++) 199 | { 200 | decoded[j] = (byte) (bytes[i] ^ masks[j%4]); 201 | } 202 | 203 | return Encoding.GetString(decoded); 204 | } 205 | 206 | #region Nested type: ReadState 207 | 208 | public class ReadState 209 | { 210 | public readonly byte[] Buffer; 211 | public readonly NetworkStream NetworkStream; 212 | public readonly StringBuilder Text; 213 | 214 | public ReadState(NetworkStream netstream, int bufferSize) 215 | { 216 | NetworkStream = netstream; 217 | Buffer = new byte[bufferSize]; 218 | Text = new StringBuilder(); 219 | } 220 | 221 | public bool HasText 222 | { 223 | get { return Text.Length > 0; } 224 | } 225 | } 226 | 227 | #endregion 228 | 229 | #region Nested type: SendState 230 | 231 | private class SendState 232 | { 233 | public readonly Action Callback; 234 | public readonly NetworkStream NetworkStream; 235 | 236 | public SendState(NetworkStream netstream, Action callback) 237 | { 238 | NetworkStream = netstream; 239 | Callback = callback; 240 | } 241 | } 242 | 243 | #endregion 244 | } 245 | } -------------------------------------------------------------------------------- /ALE.Http/Static.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | 5 | namespace ALE.Http 6 | { 7 | public class Static 8 | { 9 | #region MimeTypes 10 | public static Dictionary MimeTypes = new Dictionary 11 | { 12 | {"ai", "application/postscript"}, 13 | {"aif", "audio/x-aiff"}, 14 | {"aifc", "audio/x-aiff"}, 15 | {"aiff", "audio/x-aiff"}, 16 | {"asc", "text/plain"}, 17 | {"atom", "application/atom+xml"}, 18 | {"au", "audio/basic"}, 19 | {"avi", "video/x-msvideo"}, 20 | {"bcpio", "application/x-bcpio"}, 21 | {"bin", "application/octet-stream"}, 22 | {"bmp", "image/bmp"}, 23 | {"cdf", "application/x-netcdf"}, 24 | {"cgm", "image/cgm"}, 25 | {"class", "application/octet-stream"}, 26 | {"cpio", "application/x-cpio"}, 27 | {"cpt", "application/mac-compactpro"}, 28 | {"csh", "application/x-csh"}, 29 | {"css", "text/css"}, 30 | {"dcr", "application/x-director"}, 31 | {"dif", "video/x-dv"}, 32 | {"dir", "application/x-director"}, 33 | {"djv", "image/vnd.djvu"}, 34 | {"djvu", "image/vnd.djvu"}, 35 | {"dll", "application/octet-stream"}, 36 | {"dmg", "application/octet-stream"}, 37 | {"dms", "application/octet-stream"}, 38 | {"doc", "application/msword"}, 39 | {"dtd", "application/xml-dtd"}, 40 | {"dv", "video/x-dv"}, 41 | {"dvi", "application/x-dvi"}, 42 | {"dxr", "application/x-director"}, 43 | {"eps", "application/postscript"}, 44 | {"etx", "text/x-setext"}, 45 | {"exe", "application/octet-stream"}, 46 | {"ez", "application/andrew-inset"}, 47 | {"gif", "image/gif"}, 48 | {"gram", "application/srgs"}, 49 | {"grxml", "application/srgs+xml"}, 50 | {"gtar", "application/x-gtar"}, 51 | {"hdf", "application/x-hdf"}, 52 | {"hqx", "application/mac-binhex40"}, 53 | {"htm", "text/html"}, 54 | {"html", "text/html"}, 55 | {"ice", "x-conference/x-cooltalk"}, 56 | {"ico", "image/x-icon"}, 57 | {"ics", "text/calendar"}, 58 | {"ief", "image/ief"}, 59 | {"ifb", "text/calendar"}, 60 | {"iges", "model/iges"}, 61 | {"igs", "model/iges"}, 62 | {"jnlp", "application/x-java-jnlp-file"}, 63 | {"jp2", "image/jp2"}, 64 | {"jpe", "image/jpeg"}, 65 | {"jpeg", "image/jpeg"}, 66 | {"jpg", "image/jpeg"}, 67 | {"js", "application/x-javascript"}, 68 | {"kar", "audio/midi"}, 69 | {"latex", "application/x-latex"}, 70 | {"lha", "application/octet-stream"}, 71 | {"lzh", "application/octet-stream"}, 72 | {"m3u", "audio/x-mpegurl"}, 73 | {"m4a", "audio/mp4a-latm"}, 74 | {"m4b", "audio/mp4a-latm"}, 75 | {"m4p", "audio/mp4a-latm"}, 76 | {"m4u", "video/vnd.mpegurl"}, 77 | {"m4v", "video/x-m4v"}, 78 | {"mac", "image/x-macpaint"}, 79 | {"man", "application/x-troff-man"}, 80 | {"mathml", "application/mathml+xml"}, 81 | {"me", "application/x-troff-me"}, 82 | {"mesh", "model/mesh"}, 83 | {"mid", "audio/midi"}, 84 | {"midi", "audio/midi"}, 85 | {"mif", "application/vnd.mif"}, 86 | {"mov", "video/quicktime"}, 87 | {"movie", "video/x-sgi-movie"}, 88 | {"mp2", "audio/mpeg"}, 89 | {"mp3", "audio/mpeg"}, 90 | {"mp4", "video/mp4"}, 91 | {"mpe", "video/mpeg"}, 92 | {"mpeg", "video/mpeg"}, 93 | {"mpg", "video/mpeg"}, 94 | {"mpga", "audio/mpeg"}, 95 | {"ms", "application/x-troff-ms"}, 96 | {"msh", "model/mesh"}, 97 | {"mxu", "video/vnd.mpegurl"}, 98 | {"nc", "application/x-netcdf"}, 99 | {"oda", "application/oda"}, 100 | {"ogg", "application/ogg"}, 101 | {"pbm", "image/x-portable-bitmap"}, 102 | {"pct", "image/pict"}, 103 | {"pdb", "chemical/x-pdb"}, 104 | {"pdf", "application/pdf"}, 105 | {"pgm", "image/x-portable-graymap"}, 106 | {"pgn", "application/x-chess-pgn"}, 107 | {"pic", "image/pict"}, 108 | {"pict", "image/pict"}, 109 | {"png", "image/png"}, 110 | {"pnm", "image/x-portable-anymap"}, 111 | {"pnt", "image/x-macpaint"}, 112 | {"pntg", "image/x-macpaint"}, 113 | {"ppm", "image/x-portable-pixmap"}, 114 | {"ppt", "application/vnd.ms-powerpoint"}, 115 | {"ps", "application/postscript"}, 116 | {"qt", "video/quicktime"}, 117 | {"qti", "image/x-quicktime"}, 118 | {"qtif", "image/x-quicktime"}, 119 | {"ra", "audio/x-pn-realaudio"}, 120 | {"ram", "audio/x-pn-realaudio"}, 121 | {"ras", "image/x-cmu-raster"}, 122 | {"rdf", "application/rdf+xml"}, 123 | {"rgb", "image/x-rgb"}, 124 | {"rm", "application/vnd.rn-realmedia"}, 125 | {"roff", "application/x-troff"}, 126 | {"rtf", "text/rtf"}, 127 | {"rtx", "text/richtext"}, 128 | {"sgm", "text/sgml"}, 129 | {"sgml", "text/sgml"}, 130 | {"sh", "application/x-sh"}, 131 | {"shar", "application/x-shar"}, 132 | {"silo", "model/mesh"}, 133 | {"sit", "application/x-stuffit"}, 134 | {"skd", "application/x-koan"}, 135 | {"skm", "application/x-koan"}, 136 | {"skp", "application/x-koan"}, 137 | {"skt", "application/x-koan"}, 138 | {"smi", "application/smil"}, 139 | {"smil", "application/smil"}, 140 | {"snd", "audio/basic"}, 141 | {"so", "application/octet-stream"}, 142 | {"spl", "application/x-futuresplash"}, 143 | {"src", "application/x-wais-source"}, 144 | {"sv4cpio", "application/x-sv4cpio"}, 145 | {"sv4crc", "application/x-sv4crc"}, 146 | {"svg", "image/svg+xml"}, 147 | {"swf", "application/x-shockwave-flash"}, 148 | {"t", "application/x-troff"}, 149 | {"tar", "application/x-tar"}, 150 | {"tcl", "application/x-tcl"}, 151 | {"tex", "application/x-tex"}, 152 | {"texi", "application/x-texinfo"}, 153 | {"texinfo", "application/x-texinfo"}, 154 | {"tif", "image/tiff"}, 155 | {"tiff", "image/tiff"}, 156 | {"tr", "application/x-troff"}, 157 | {"tsv", "text/tab-separated-values"}, 158 | {"txt", "text/plain"}, 159 | {"ustar", "application/x-ustar"}, 160 | {"vcd", "application/x-cdlink"}, 161 | {"vrml", "model/vrml"}, 162 | {"vxml", "application/voicexml+xml"}, 163 | {"wav", "audio/x-wav"}, 164 | {"wbmp", "image/vnd.wap.wbmp"}, 165 | {"wbmxl", "application/vnd.wap.wbxml"}, 166 | {"wml", "text/vnd.wap.wml"}, 167 | {"wmlc", "application/vnd.wap.wmlc"}, 168 | {"wmls", "text/vnd.wap.wmlscript"}, 169 | {"wmlsc", "application/vnd.wap.wmlscriptc"}, 170 | {"wrl", "model/vrml"}, 171 | {"xbm", "image/x-xbitmap"}, 172 | {"xht", "application/xhtml+xml"}, 173 | {"xhtml", "application/xhtml+xml"}, 174 | {"xls", "application/vnd.ms-excel"}, 175 | {"xml", "application/xml"}, 176 | {"xpm", "image/x-xpixmap"}, 177 | {"xsl", "application/xml"}, 178 | {"xslt", "application/xslt+xml"}, 179 | {"xul", "application/vnd.mozilla.xul+xml"}, 180 | {"xwd", "image/x-xwindowdump"}, 181 | {"xyz", "chemical/x-xyz"}, 182 | {"zip", "application/zip"} 183 | }; 184 | #endregion 185 | 186 | public static Action Directory(string path) 187 | { 188 | if (String.IsNullOrWhiteSpace(path)) 189 | { 190 | path = "/"; 191 | } 192 | 193 | var staticRoot = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path.Replace("/", "\\").TrimStart('\\'))); 194 | 195 | return (context, next) => 196 | { 197 | var res = context.Response; 198 | var req = context.Request; 199 | var absPath = req.Url.AbsolutePath; 200 | var unUrlified = Uri.UnescapeDataString(absPath.Replace("/", "\\")).TrimStart('\\'); 201 | var filePath = Path.Combine(staticRoot, unUrlified); 202 | var fullPath = Path.GetFullPath(filePath); 203 | if (!fullPath.StartsWith(staticRoot)) 204 | { 205 | throw new InvalidOperationException("File path disallowed."); 206 | } 207 | if (File.Exists(filePath)) 208 | { 209 | FileSystem.File.ReadAllBytes(filePath, (ex, buffer) => 210 | { 211 | if (ex != null) 212 | { 213 | res.StatusCode = 500; 214 | res.StatusDescription = "Internal server error."; 215 | } else 216 | { 217 | res.StatusCode = 200; 218 | res.ContentType = GetMimeType(filePath); 219 | res.Write(buffer); 220 | } 221 | res.Send(); 222 | }); 223 | } else 224 | { 225 | next(); 226 | } 227 | }; 228 | } 229 | 230 | public static string GetMimeType(string filepath) 231 | { 232 | var ext = Path.GetExtension(filepath).ToLower().Substring(1); 233 | return MimeTypes[ext]; 234 | } 235 | } 236 | } -------------------------------------------------------------------------------- /_UpgradeReport_Files/UpgradeReport.xslt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | \ 36 | 37 | 38 | 39 | Solution 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | Error 87 | Warning 88 | Success 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | Message 117 | Warning 118 | Error 119 | Message 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 174 | 191 | 194 | 204 | 214 | 228 | 229 | 230 |
ProjectPathErrorsWarningsMessages
161 | 162 | 163 | 164 | _UpgradeReport_Files\UpgradeReport_Error.png 165 | _UpgradeReport_Files\UpgradeReport_Warning.png 166 | _UpgradeReport_Files\UpgradeReport_Success.png 167 | 168 | 169 | 170 | 171 | 172 | 173 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | Solution 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 192 | 193 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 215 | 216 | 217 | 218 | 219 | ' 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 |
231 |
232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | ' 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | Show additional messages 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | ' 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | Hide additional messages 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | display: none 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | _UpgradeReport_Files\UpgradeReport_Error.png 309 | _UpgradeReport_Files\UpgradeReport_Warning.png 310 | _UpgradeReport_Files\UpgradeReport_Information.png 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | : 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 |

Solution

347 |
348 | 349 |

350 | 351 |

352 |
353 |
354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 390 | 391 | 392 | 395 | 396 | 397 | 400 | 401 | 402 | 403 | 404 | 405 |
Message
388 | 389 | 393 | Solution logged no messages. 394 | 398 | logged no messages. 399 |
406 |
407 |
408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | ]]> 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | Migration Report 424 | 425 | 426 | 532 | 533 | 534 |

535 | Migration Report - 536 |

537 | 538 |
539 |

Overview

540 | 541 | 542 | 543 | 544 |
545 | 546 |
547 | 548 |

Solution and projects

549 | 550 |
551 | 552 |
553 |
554 | 555 | 556 |
557 | 558 |
--------------------------------------------------------------------------------