From c247ea1b42b258041a3e8d4e590173803c8c614e Mon Sep 17 00:00:00 2001 From: Robert Stiff Date: Sat, 9 Dec 2017 15:20:23 +0000 Subject: [PATCH 01/29] Build core components for dotnet core and aspnet core contexts. --- .../Inversion.Demo.Katana.csproj | 118 ++------- Inversion.Demo.Katana/InversionStartup.cs | 80 ------ Inversion.Demo.Katana/Program.cs | 35 +-- .../Properties/AssemblyInfo.cs | 36 --- Inversion.Demo.Katana/Startup.cs | 228 ++++++++++++++++++ Inversion.Naiad/Inversion.Naiad.csproj | 72 +----- Inversion.Naiad/Properties/AssemblyInfo.cs | 35 --- Inversion.Process/Inversion.Process.csproj | 129 +--------- Inversion.Process/Properties/AssemblyInfo.cs | 35 --- Inversion.Web/Inversion.Web.csproj | 126 +--------- Inversion.Web/Properties/AssemblyInfo.cs | 35 --- Inversion.Web/packages.config | 7 - Inversion/DataView.cs | 2 +- Inversion/Inversion.csproj | 90 +------ Inversion/JDataObject.cs | 7 +- Inversion/Properties/AssemblyInfo.cs | 35 --- inversion-dev.sln | 153 +++++------- 17 files changed, 362 insertions(+), 861 deletions(-) delete mode 100644 Inversion.Demo.Katana/InversionStartup.cs delete mode 100644 Inversion.Demo.Katana/Properties/AssemblyInfo.cs create mode 100644 Inversion.Demo.Katana/Startup.cs delete mode 100644 Inversion.Naiad/Properties/AssemblyInfo.cs delete mode 100644 Inversion.Process/Properties/AssemblyInfo.cs delete mode 100644 Inversion.Web/Properties/AssemblyInfo.cs delete mode 100644 Inversion.Web/packages.config delete mode 100644 Inversion/Properties/AssemblyInfo.cs diff --git a/Inversion.Demo.Katana/Inversion.Demo.Katana.csproj b/Inversion.Demo.Katana/Inversion.Demo.Katana.csproj index fead848..8e70810 100644 --- a/Inversion.Demo.Katana/Inversion.Demo.Katana.csproj +++ b/Inversion.Demo.Katana/Inversion.Demo.Katana.csproj @@ -1,111 +1,23 @@ - - - + + - Debug - AnyCPU - {99FEB4FE-13C4-4E6D-9D2B-93BAE4E3E70E} - Exe - Properties - Inversion.Demo.Katana - Inversion.Demo.Katana - v4.5.2 - 512 - + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - $(SolutionDir)packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll - True - - - $(SolutionDir)packages\Microsoft.Owin.Diagnostics.3.0.0\lib\net45\Microsoft.Owin.Diagnostics.dll - - - $(SolutionDir)packages\Microsoft.Owin.Host.HttpListener.3.0.0\lib\net45\Microsoft.Owin.Host.HttpListener.dll - - - $(SolutionDir)packages\Microsoft.Owin.Hosting.3.0.1\lib\net45\Microsoft.Owin.Hosting.dll - True - - - $(SolutionDir)packages\Owin.1.0\lib\net40\Owin.dll - - - - - - - - - + - - - + + - - - - - - - - - + + + - - {975446b0-dbc2-498f-94d4-2a6a20f9c5d0} - Inversion.Naiad - - - {37F59768-76EA-4D09-8976-BBC3540DB5AE} - Inversion.Process - - - {DC33EDC0-055F-4369-A703-FA4F20169C56} - Inversion.StringTemplate - - - {98265346-6764-47CA-9E09-864848DA183E} - Inversion.Web.Owin - - - {6951BA6B-4388-4FC8-8298-60DA7563FEE4} - Inversion.Web - - - {A2DBF0B8-B672-4237-8A0B-864BB0474054} - Inversion - + + + + - - - \ No newline at end of file + + diff --git a/Inversion.Demo.Katana/InversionStartup.cs b/Inversion.Demo.Katana/InversionStartup.cs deleted file mode 100644 index e5acf3b..0000000 --- a/Inversion.Demo.Katana/InversionStartup.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.Owin; -using Owin; - -using Inversion.Process; -using Inversion.Process.Behaviour; -using Inversion.Data; -using Inversion.StringTemplate.Behaviour.View; -using Inversion.Web; -using Inversion.Web.Owin; -using Inversion.Web.Behaviour; -using Inversion.Web.Behaviour.View; -using Inversion.Naiad; - -[assembly: OwinStartup(typeof(Inversion.Demo.Katana.InversionStartup))] - -namespace Inversion.Demo.Katana { - public class InversionStartup { - public void Configuration(IAppBuilder app) { - - Naiad.ServiceContainer.Instance.RegisterService("request-behaviours", - container => { - return new List { - new MessageTraceBehaviour("*", new Prototype.Builder { - {"event", "match", "trace", "true"} - } - ), - new ParameterisedSequenceBehaviour("process-request", new Configuration.Builder { - {"fire", "bootstrap"}, - {"fire", "parse-request"}, - {"fire", "work"}, - {"fire", "view-state"}, - {"fire", "process-views"}, - {"fire", "render"} - } - ), - new ParameterisedSequenceBehaviour("work", new Configuration.Builder { - {"context", "match-any", "action", "test1"}, - {"context", "match-any", "action", "test2"}, - {"fire", "work-message-one", "trace", "true"}, - {"fire", "work-message-two", "trace", "true"} - } - ), - new ParseRequestBehaviour("parse-request"), - new BootstrapBehaviour("bootstrap", new Configuration.Builder { - {"context", "set", "area", "default"}, - {"context", "set", "concern", "default"}, - {"context", "set", "action", "default"}, - {"context", "set", "appPath", "/web.harness"} - } - ), - new ViewStateBehaviour("view-state"), - new ProcessViewsBehaviour("process-views", new Configuration.Builder { - {"config", "default-view", "xml"} - } - ), - new RenderBehaviour("render"), - new JsonViewBehaviour("json::view", "text/json"), - new XmlViewBehaviour("xml::view", "text/xml"), - new XsltViewBehaviour("xslt::view", "text/xml"), - new XsltViewBehaviour("xsl::view", "text/html"), - new StringTemplateViewBehaviour("st::view", "text/html") - }; - } - ); - - app.Run(owin => Task.Run(() => { - IWebContext context = new OwinProcessContext(owin, ServiceContainer.Instance, new FileSystemResourceAdapter(@"e:\Users\User\Documents\GitHub\inversion-dev\Inversion.Demo.Katana")); - IList behaviours = context.Services.GetService>("request-behaviours"); - context.Register(behaviours); - - context.Timers.Begin("process-request"); - context.Fire("process-request"); - context.Completed(); - })); - } - } -} diff --git a/Inversion.Demo.Katana/Program.cs b/Inversion.Demo.Katana/Program.cs index 7cc8d46..1d2a7d4 100644 --- a/Inversion.Demo.Katana/Program.cs +++ b/Inversion.Demo.Katana/Program.cs @@ -1,18 +1,25 @@ using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; -using Microsoft.Owin.Hosting; +namespace Inversion.Demo.Katana +{ + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } -namespace Inversion.Demo.Katana { - public class Program { - static void Main(string[] args) { - string url = "http://localhost:9000"; - string factoryName = "Microsoft.Owin.Host.HttpListener"; - using (Microsoft.Owin.Hosting.WebApp.Start(new StartOptions(url){ServerFactory = factoryName})) { - Console.WriteLine("Now serving from: {0}", url); - Console.WriteLine("Press [enter] to quit..."); - Console.ReadLine(); - - } - } - } + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .Build(); + } } diff --git a/Inversion.Demo.Katana/Properties/AssemblyInfo.cs b/Inversion.Demo.Katana/Properties/AssemblyInfo.cs deleted file mode 100644 index 4f0c825..0000000 --- a/Inversion.Demo.Katana/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Inversion.Demo.Katana")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Inversion.Demo.Katana")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6f04bb7e-64c7-49a1-949d-19a45323a61b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Inversion.Demo.Katana/Startup.cs b/Inversion.Demo.Katana/Startup.cs new file mode 100644 index 0000000..d464317 --- /dev/null +++ b/Inversion.Demo.Katana/Startup.cs @@ -0,0 +1,228 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +using Inversion.Process; +using Inversion.Process.Behaviour; +using Inversion.Data; +// using Inversion.StringTemplate.Behaviour.View; +using Inversion.Web; +// using Inversion.Web.Owin; +using Inversion.Web.Behaviour; +using Inversion.Web.Behaviour.View; +using Inversion.Naiad; +using Inversion.Collections; +using System.Security.Principal; +using System.IO; +using Microsoft.AspNetCore.Http.Features; + +namespace Inversion.Demo.Katana +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + + Naiad.ServiceContainer.Instance.RegisterService("request-behaviours", + container => { + return new List { + new MessageTraceBehaviour("*", new Prototype.Builder { + {"event", "match", "trace", "true"} + } + ), + new ParameterisedSequenceBehaviour("process-request", new Configuration.Builder { + {"fire", "bootstrap"}, + {"fire", "parse-request"}, + {"fire", "work"}, + {"fire", "view-state"}, + {"fire", "process-views"}, + {"fire", "render"} + } + ), + new ParameterisedSequenceBehaviour("work", new Configuration.Builder { + {"context", "match-any", "action", "test1"}, + {"context", "match-any", "action", "test2"}, + {"fire", "work-message-one", "trace", "true"}, + {"fire", "work-message-two", "trace", "true"} + } + ), + new ParseRequestBehaviour("parse-request"), + new BootstrapBehaviour("bootstrap", new Configuration.Builder { + {"context", "set", "area", "default"}, + {"context", "set", "concern", "default"}, + {"context", "set", "action", "default"}, + {"context", "set", "appPath", "/web.harness"} + } + ), + new ViewStateBehaviour("view-state"), + new ProcessViewsBehaviour("process-views", new Configuration.Builder { + {"config", "default-view", "xml"} + } + ), + new RenderBehaviour("render"), + new JsonViewBehaviour("json::view", "text/json"), + new XmlViewBehaviour("xml::view", "text/xml"), + new XsltViewBehaviour("xslt::view", "text/xml"), + new XsltViewBehaviour("xsl::view", "text/html"), + // new StringTemplateViewBehaviour("st::view", "text/html") + }; + } + ); + + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.Run(async (context) => + { + IWebContext webContext = new AspNetCoreContext(context, ServiceContainer.Instance, new FileSystemResourceAdapter(@"e:\Users\User\Documents\GitHub\inversion-dev\Inversion.Demo.Katana")); + IList behaviours = webContext.Services.GetService>("request-behaviours"); + webContext.Register(behaviours); + + webContext.Timers.Begin("process-request"); + webContext.Fire("process-request"); + webContext.Completed(); + }); + } + } + + public class AspNetCoreContext : ProcessContext, IWebContext + { + public IWebApplication Application => throw new NotImplementedException(); + + public IWebResponse Response => new AspNetCoreWebResponse(this.context); + + public IWebRequest Request => new AspNetCoreWebRequest(this.context); + + public IPrincipal User { get => this.context.User; set => throw new NotImplementedException(); } + + + private HttpContext context; + + public AspNetCoreContext(HttpContext context, ServiceContainer services, FileSystemResourceAdapter resources) + : base(services, resources) + { + this.context = context; + } + } + + internal class AspNetCoreWebRequest : IWebRequest + { + private HttpContext context; + + public AspNetCoreWebRequest(HttpContext context) + { + this.context = context; + } + + public IRequestFilesCollection Files => throw new NotImplementedException(); + + // TODO: convert this less weird. The port is missing. + public UrlInfo UrlInfo => new UrlInfo(new Uri($"{this.context.Request.Protocol}://{this.context.Request.Host}/{this.context.Request.Path.Value}?{this.context.Request.QueryString}")); + + public string Method => this.context.Request.Method; + + public bool IsGet => this.Method.ToLower() == "get"; + + public bool IsPost => this.Method.ToLower() == "post"; + + public IDictionary Params => throw new NotImplementedException(); + + public string Payload => this.context.Request.Body.AsText(); + + public IEnumerable Flags => this.context.Request.Query.Where(x => string.IsNullOrEmpty(x.Value)).Select(x => x.Key); + + public IDictionary Headers => this.context.Request.Headers.ToDictionary(x => x.Key, x => string.Join(",", x.Value)); + + public Web.IRequestCookieCollection Cookies => throw new NotImplementedException(); + } + + internal class AspNetCoreWebResponse : IWebResponse + { + private HttpContext context; + + public AspNetCoreWebResponse(HttpContext context) + { + this.context = context; + } + + public TextWriter Output => new StreamWriter(this.OutputStream); + + public Stream OutputStream => this.context.Response.Body; + + public int StatusCode { get => this.context.Response.StatusCode; set => this.context.Response.StatusCode = value; } + public string StatusDescription { + get + { + return context.Response.HttpContext.Features.Get().ReasonPhrase; + } + set + { + context.Response.HttpContext.Features.Get().ReasonPhrase = value; + } + } + + public string ContentType { get => this.context.Response.ContentType; set => this.context.Response.ContentType = value; } + + public IResponseCookieCollection Cookies => throw new NotImplementedException(); + + public IResponseHeaderCollection Headers => throw new NotImplementedException(); + + /// + /// Flushes the response steam and ends the response. + /// + public void End() { + // nothing to do on an OWIN implementation that is apparent to me at this point. + } + + /// + /// Writes the provided text to the response stream. + /// + /// The text to write to the response stream. + public void Write(string text) { + this.Output.Write(text); + } + + /// + /// Writes the provided formatted text to the response stream. + /// + /// The text to write to the response stream. + /// The arguments to interpolate into the text. + public void WriteFormat(string text, params object[] args) { + this.Output.Write(string.Format(text, args)); + } + + /// + /// Redirects the request to the provided url. + /// + /// The url to redirect to. + public void Redirect(string url) { + this.context.Response.Redirect(url); + } + + /// + /// Redirects the request permanently to the provided url + /// issuing a `301` in the response. + /// + /// + public void PermanentRedirect(string url) { + this.StatusCode = 301; + this.StatusDescription = "301 Moved Permanently"; + this.context.Response.Headers.Append("Location", url); + } + } +} diff --git a/Inversion.Naiad/Inversion.Naiad.csproj b/Inversion.Naiad/Inversion.Naiad.csproj index 2f4f003..c26c375 100644 --- a/Inversion.Naiad/Inversion.Naiad.csproj +++ b/Inversion.Naiad/Inversion.Naiad.csproj @@ -1,65 +1,11 @@ - - - - - Debug - AnyCPU - {975446B0-DBC2-498F-94D4-2A6A20F9C5D0} - Library - Properties - Inversion.Naiad - Inversion.Naiad - v4.5.2 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - + + - - {37f59768-76ea-4d09-8976-bbc3540db5ae} - Inversion.Process - - - {a2dbf0b8-b672-4237-8a0b-864bb0474054} - Inversion - + - - - \ No newline at end of file + + + netstandard2.0 + + + diff --git a/Inversion.Naiad/Properties/AssemblyInfo.cs b/Inversion.Naiad/Properties/AssemblyInfo.cs deleted file mode 100644 index 4d6cd4b..0000000 --- a/Inversion.Naiad/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Inversion.Naiad")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Inversion.Naiad")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("dbfa736b-22d3-4731-b399-e56698e78ed6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Inversion.Process/Inversion.Process.csproj b/Inversion.Process/Inversion.Process.csproj index 9a8c3b5..1d0e0d4 100644 --- a/Inversion.Process/Inversion.Process.csproj +++ b/Inversion.Process/Inversion.Process.csproj @@ -1,126 +1,13 @@ - - - - - Debug - AnyCPU - {37F59768-76EA-4D09-8976-BBC3540DB5AE} - Library - Properties - Inversion.Process - Inversion.Process - v4.5.2 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\Inversion.Process.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - $(SolutionDir)packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - - False - $(SolutionDir)packages\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll - - - - $(SolutionDir)packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll - - - $(SolutionDir)packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll - - - $(SolutionDir)packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll - - - $(SolutionDir)packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - {a2dbf0b8-b672-4237-8a0b-864bb0474054} - Inversion - + + + netstandard2.0 + - - - - + + + - - \ No newline at end of file diff --git a/Inversion.Process/Properties/AssemblyInfo.cs b/Inversion.Process/Properties/AssemblyInfo.cs deleted file mode 100644 index b6be507..0000000 --- a/Inversion.Process/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Inversion.Process")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Inversion.Process")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("854d8ed0-6078-4a86-9d7b-15be43c4d4a7")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index efd5f62..c26c375 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -1,119 +1,11 @@ - - - - - Debug - AnyCPU - {6951BA6B-4388-4FC8-8298-60DA7563FEE4} - Library - Properties - Inversion.Web - Inversion.Web - v4.5.2 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\Inversion.Web.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - $(SolutionDir)packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - True - - - $(SolutionDir)packages\RazorEngine.3.4.1\lib\net45\RazorEngine.dll - - - - False - $(SolutionDir)packages\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll - - - - - - False - $(SolutionDir)packages\Microsoft.AspNet.Razor.3.0.0\lib\net45\System.Web.Razor.dll - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - {37f59768-76ea-4d09-8976-bbc3540db5ae} - Inversion.Process - - - {a2dbf0b8-b672-4237-8a0b-864bb0474054} - Inversion - - - - - - - - - - - \ No newline at end of file + + + netstandard2.0 + + + diff --git a/Inversion.Web/Properties/AssemblyInfo.cs b/Inversion.Web/Properties/AssemblyInfo.cs deleted file mode 100644 index 05dcfd3..0000000 --- a/Inversion.Web/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Inversion.Web")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Inversion.Web")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f951738f-061a-46de-9d77-935b4f35512e")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Inversion.Web/packages.config b/Inversion.Web/packages.config deleted file mode 100644 index 46c360f..0000000 --- a/Inversion.Web/packages.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Inversion/DataView.cs b/Inversion/DataView.cs index d1ce764..88acfe2 100644 --- a/Inversion/DataView.cs +++ b/Inversion/DataView.cs @@ -42,7 +42,7 @@ public DataView(IData other) { _xml = other.ToXml(); _json = other.ToJson(); _data = other.ToJsonObject(); - _data.PropertyChanging += (sender, args) => { + _data.PropertyChanged += (sender, args) => { throw new InvalidOperationException("You may not change the data representation participating in a data view."); }; } diff --git a/Inversion/Inversion.csproj b/Inversion/Inversion.csproj index 8989ea9..60eefdf 100644 --- a/Inversion/Inversion.csproj +++ b/Inversion/Inversion.csproj @@ -1,92 +1,8 @@ - - - + - Debug - AnyCPU - {A2DBF0B8-B672-4237-8A0B-864BB0474054} - Library - Properties - Inversion - Inversion - v4.5.2 - 512 - + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\Inversion.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - $(SolutionDir)packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - \ No newline at end of file diff --git a/Inversion/JDataObject.cs b/Inversion/JDataObject.cs index bd42636..c52cbf5 100644 --- a/Inversion/JDataObject.cs +++ b/Inversion/JDataObject.cs @@ -53,5 +53,10 @@ public void ToXml(XmlWriter writer) { public void ToJson(JsonWriter writer) { writer.WriteRaw(this.ToString()); } - } + + public object Clone() + { + return base.DeepClone(); + } + } } diff --git a/Inversion/Properties/AssemblyInfo.cs b/Inversion/Properties/AssemblyInfo.cs deleted file mode 100644 index 1827fde..0000000 --- a/Inversion/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Inversion")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Inversion")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0bf39764-5c61-44d0-9457-ea54caa42299")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/inversion-dev.sln b/inversion-dev.sln index f0ed4cd..4ebbfd9 100644 --- a/inversion-dev.sln +++ b/inversion-dev.sln @@ -1,105 +1,76 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion", "Inversion\Inversion.csproj", "{A2DBF0B8-B672-4237-8A0B-864BB0474054}" +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Demo.Katana", "Inversion.Demo.Katana\Inversion.Demo.Katana.csproj", "{02A7C04D-3A85-4839-BD60-13AB63367A04}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Process", "Inversion.Process\Inversion.Process.csproj", "{37F59768-76EA-4D09-8976-BBC3540DB5AE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Process", "Inversion.Process\Inversion.Process.csproj", "{33017658-0806-43CB-B73A-41DEAF4499AB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Spring", "Inversion.Spring\Inversion.Spring.csproj", "{E50603E3-E170-4F0B-9E25-0DF068A77096}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion", "Inversion\Inversion.csproj", "{523D340C-59E7-424D-BC67-B663744203ED}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Web", "Inversion.Web\Inversion.Web.csproj", "{6951BA6B-4388-4FC8-8298-60DA7563FEE4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Documentation.Generator", "Inversion.Documentation.Generator\Inversion.Documentation.Generator.csproj", "{57DAFD0A-93FB-458F-8788-D6E33101C76D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6B05B2B6-510B-4391-A085-F937452ACFDF}" - ProjectSection(SolutionItems) = preProject - Solution.md = Solution.md - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Web.Harness.Site", "Inversion.Web.Harness.Site\Inversion.Web.Harness.Site.csproj", "{F83C4657-B9BB-4481-9F49-6CD5DF5D9E72}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Web.Harness", "Inversion.Web.Harness\Inversion.Web.Harness.csproj", "{B2183BFD-9C0E-48AA-B426-4912CE1DADC7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Naiad", "Inversion.Naiad\Inversion.Naiad.csproj", "{975446B0-DBC2-498F-94D4-2A6A20F9C5D0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.StringTemplate", "Inversion.StringTemplate\Inversion.StringTemplate.csproj", "{DC33EDC0-055F-4369-A703-FA4F20169C56}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Process.Tests", "Inversion.Process.Tests\Inversion.Process.Tests.csproj", "{E98E256B-0F9C-4305-BC62-8C1D311B2833}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Web.Tests", "Inversion.Web.Tests\Inversion.Web.Tests.csproj", "{0FFBE678-1F81-47EA-A4BF-D6C8190DA764}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Web.AspNet", "Inversion.Web.AspNet\Inversion.Web.AspNet.csproj", "{FAAD5EAA-3432-4B69-B334-DE4864EFA213}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Web.Owin", "Inversion.Web.Owin\Inversion.Web.Owin.csproj", "{98265346-6764-47CA-9E09-864848DA183E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Demo.Katana", "Inversion.Demo.Katana\Inversion.Demo.Katana.csproj", "{99FEB4FE-13C4-4E6D-9D2B-93BAE4E3E70E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Web", "Inversion.Web\Inversion.Web.csproj", "{F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A2DBF0B8-B672-4237-8A0B-864BB0474054}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A2DBF0B8-B672-4237-8A0B-864BB0474054}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A2DBF0B8-B672-4237-8A0B-864BB0474054}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A2DBF0B8-B672-4237-8A0B-864BB0474054}.Release|Any CPU.Build.0 = Release|Any CPU - {37F59768-76EA-4D09-8976-BBC3540DB5AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {37F59768-76EA-4D09-8976-BBC3540DB5AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {37F59768-76EA-4D09-8976-BBC3540DB5AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {37F59768-76EA-4D09-8976-BBC3540DB5AE}.Release|Any CPU.Build.0 = Release|Any CPU - {E50603E3-E170-4F0B-9E25-0DF068A77096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E50603E3-E170-4F0B-9E25-0DF068A77096}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E50603E3-E170-4F0B-9E25-0DF068A77096}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E50603E3-E170-4F0B-9E25-0DF068A77096}.Release|Any CPU.Build.0 = Release|Any CPU - {6951BA6B-4388-4FC8-8298-60DA7563FEE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6951BA6B-4388-4FC8-8298-60DA7563FEE4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6951BA6B-4388-4FC8-8298-60DA7563FEE4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6951BA6B-4388-4FC8-8298-60DA7563FEE4}.Release|Any CPU.Build.0 = Release|Any CPU - {57DAFD0A-93FB-458F-8788-D6E33101C76D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {57DAFD0A-93FB-458F-8788-D6E33101C76D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {57DAFD0A-93FB-458F-8788-D6E33101C76D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {57DAFD0A-93FB-458F-8788-D6E33101C76D}.Release|Any CPU.Build.0 = Release|Any CPU - {F83C4657-B9BB-4481-9F49-6CD5DF5D9E72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F83C4657-B9BB-4481-9F49-6CD5DF5D9E72}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F83C4657-B9BB-4481-9F49-6CD5DF5D9E72}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F83C4657-B9BB-4481-9F49-6CD5DF5D9E72}.Release|Any CPU.Build.0 = Release|Any CPU - {B2183BFD-9C0E-48AA-B426-4912CE1DADC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B2183BFD-9C0E-48AA-B426-4912CE1DADC7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B2183BFD-9C0E-48AA-B426-4912CE1DADC7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B2183BFD-9C0E-48AA-B426-4912CE1DADC7}.Release|Any CPU.Build.0 = Release|Any CPU - {975446B0-DBC2-498F-94D4-2A6A20F9C5D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {975446B0-DBC2-498F-94D4-2A6A20F9C5D0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {975446B0-DBC2-498F-94D4-2A6A20F9C5D0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {975446B0-DBC2-498F-94D4-2A6A20F9C5D0}.Release|Any CPU.Build.0 = Release|Any CPU - {DC33EDC0-055F-4369-A703-FA4F20169C56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DC33EDC0-055F-4369-A703-FA4F20169C56}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DC33EDC0-055F-4369-A703-FA4F20169C56}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DC33EDC0-055F-4369-A703-FA4F20169C56}.Release|Any CPU.Build.0 = Release|Any CPU - {E98E256B-0F9C-4305-BC62-8C1D311B2833}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E98E256B-0F9C-4305-BC62-8C1D311B2833}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E98E256B-0F9C-4305-BC62-8C1D311B2833}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E98E256B-0F9C-4305-BC62-8C1D311B2833}.Release|Any CPU.Build.0 = Release|Any CPU - {0FFBE678-1F81-47EA-A4BF-D6C8190DA764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0FFBE678-1F81-47EA-A4BF-D6C8190DA764}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0FFBE678-1F81-47EA-A4BF-D6C8190DA764}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0FFBE678-1F81-47EA-A4BF-D6C8190DA764}.Release|Any CPU.Build.0 = Release|Any CPU - {FAAD5EAA-3432-4B69-B334-DE4864EFA213}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FAAD5EAA-3432-4B69-B334-DE4864EFA213}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FAAD5EAA-3432-4B69-B334-DE4864EFA213}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FAAD5EAA-3432-4B69-B334-DE4864EFA213}.Release|Any CPU.Build.0 = Release|Any CPU - {98265346-6764-47CA-9E09-864848DA183E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {98265346-6764-47CA-9E09-864848DA183E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {98265346-6764-47CA-9E09-864848DA183E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {98265346-6764-47CA-9E09-864848DA183E}.Release|Any CPU.Build.0 = Release|Any CPU - {99FEB4FE-13C4-4E6D-9D2B-93BAE4E3E70E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {99FEB4FE-13C4-4E6D-9D2B-93BAE4E3E70E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {99FEB4FE-13C4-4E6D-9D2B-93BAE4E3E70E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {99FEB4FE-13C4-4E6D-9D2B-93BAE4E3E70E}.Release|Any CPU.Build.0 = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x64.ActiveCfg = Debug|x64 + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x64.Build.0 = Debug|x64 + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x86.ActiveCfg = Debug|x86 + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x86.Build.0 = Debug|x86 + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|Any CPU.Build.0 = Release|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x64.ActiveCfg = Release|x64 + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x64.Build.0 = Release|x64 + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x86.ActiveCfg = Release|x86 + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x86.Build.0 = Release|x86 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x64.ActiveCfg = Debug|x64 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x64.Build.0 = Debug|x64 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x86.ActiveCfg = Debug|x86 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x86.Build.0 = Debug|x86 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|Any CPU.Build.0 = Release|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x64.ActiveCfg = Release|x64 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x64.Build.0 = Release|x64 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x86.ActiveCfg = Release|x86 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x86.Build.0 = Release|x86 + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x64.ActiveCfg = Debug|x64 + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x64.Build.0 = Debug|x64 + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x86.ActiveCfg = Debug|x86 + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x86.Build.0 = Debug|x86 + {523D340C-59E7-424D-BC67-B663744203ED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Release|Any CPU.Build.0 = Release|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Release|x64.ActiveCfg = Release|x64 + {523D340C-59E7-424D-BC67-B663744203ED}.Release|x64.Build.0 = Release|x64 + {523D340C-59E7-424D-BC67-B663744203ED}.Release|x86.ActiveCfg = Release|x86 + {523D340C-59E7-424D-BC67-B663744203ED}.Release|x86.Build.0 = Release|x86 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x64.ActiveCfg = Debug|x64 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x64.Build.0 = Debug|x64 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x86.ActiveCfg = Debug|x86 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x86.Build.0 = Debug|x86 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|Any CPU.Build.0 = Release|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x64.ActiveCfg = Release|x64 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x64.Build.0 = Release|x64 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x86.ActiveCfg = Release|x86 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x86.Build.0 = Release|x86 + EndGlobalSection EndGlobal From 0e218e8e7298d9ad380042018ff57cad2448593d Mon Sep 17 00:00:00 2001 From: Robert Stiff Date: Sat, 9 Dec 2017 15:31:39 +0000 Subject: [PATCH 02/29] Razor should have been omitted until it builds. --- .../Behaviour/View/RazorViewBehaviour.cs | 282 +++++++++--------- 1 file changed, 141 insertions(+), 141 deletions(-) diff --git a/Inversion.Web/Behaviour/View/RazorViewBehaviour.cs b/Inversion.Web/Behaviour/View/RazorViewBehaviour.cs index 50ee13a..fe5ffb9 100644 --- a/Inversion.Web/Behaviour/View/RazorViewBehaviour.cs +++ b/Inversion.Web/Behaviour/View/RazorViewBehaviour.cs @@ -1,141 +1,141 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Inversion.Data; -using RazorEngine; -using RazorEngine.Templating; - -using Inversion.Process; -using Inversion.Collections; - -namespace Inversion.Web.Behaviour.View { - - /// - /// A web behaviour that resolves razor templates to generate views. - /// - /// - /// - /// Razor isn't getting a lot of attention in Inversion initially, at - /// some point I'll pay it some attention, but it's really not a priority - /// as personally I'm not a big fan. - /// - /// - /// Razor is the fast food of templating. It's really tasting - /// and super-saturated with utility, and it's bad for you. - /// When rendering a view you really shouldn't be able to - /// yield side-effects, and you shouldn't be able to consider - /// anything other than the view you're rendering. In Razor - /// you can do anything you want. And you will. Especially - /// when people aren't looking. - /// - /// - /// Worse, you'll start architecting clever helpers, and mappings, - /// and... you'll start refactoring, and all your templates will - /// become enmeshed in one glorious front-end monolith. - /// - /// - /// Razor. Just say "no"... Okay, I'm over-egging it a bit. - /// - /// - /// Joking aside, I get why Razor is so popular. It's simple, bendy, - /// easy for .NET devs to dive into, and you can brute force yourself - /// out of any situation. It does however in my view encourage - /// poor practice and blurs an important application layer - /// so the middle and front of the application risk becoming - /// quickly enmeshed. - /// - /// - /// Conclave favours XML/XSL, I understand why you - /// might not, hence . - /// - /// - public class RazorViewBehaviour : WebBehaviour { - - private readonly string _contentType; - - /// - /// - /// - /// - /// - /// This constructor defaults the content type to `text/html`. - /// - public RazorViewBehaviour(string respondsTo) : this(respondsTo, "text/html") { } - - /// - /// - /// - /// - /// - public RazorViewBehaviour(string respondsTo, string contentType) - : base(respondsTo) { - _contentType = contentType; - } - - // TODO: confirm thread safe - // The iterator generated for this should be - // ThreadLocal and therefore safe to use - // in this manner on a singleton, would be - // nice to fonfirm this. - private IEnumerable _possibleTemplates(IWebContext context) { - string area = context.Params["area"]; - string concern = context.Params["concern"]; - string action = String.Format("{0}.cshtml", context.Params["action"]); - - // area/concern/action - yield return Path.Combine(area, concern, action); - yield return Path.Combine(area, concern, "default.cshtml"); - // area/action - yield return Path.Combine(area, action); - yield return Path.Combine(area, "default.cshtml"); - // action - yield return action; - yield return "default.cshtml"; - - } - - /// - /// Tranforms the last view-step using a razor template. - /// - /// The vent that was considered for this action. - /// The context to act upon. - public override void Action(IEvent ev, IWebContext context) { - - if (context.ViewSteps.HasSteps && context.ViewSteps.Last.HasModel) { // we should have a model that we're going to render - - DataDictionary viewState = context.ViewSteps.Last.Model as DataDictionary; - - string content = String.Empty; // default output if we can't process a template - - foreach (string templateName in _possibleTemplates(context)) { // check each possible template in turn - // This is the most immediate way I found to check if a template has been compiled - // but we don't actually use the returned template as I can't find how to get a razor context - // to run against, when I do this code will probably chage with a possible early bail here. - ITemplate compiledTemplate = Razor.Resolve(templateName); - - bool compiled = false; - if (compiledTemplate == null) { // we'll need to look for the template - string templatePath = Path.Combine("Resources", "Views", "Razor", templateName); - if (context.Resources.Exists(templatePath)) { - string template = context.Resources.Open(templatePath).AsText(); - Razor.Compile(template, viewState.GetType(), templateName); - compiled = true; - } else { - continue; - } - } - if (compiledTemplate != null || compiled) { - content = Razor.Run(templateName, viewState); - } - - if (!String.IsNullOrEmpty(content)) { // we have content so create the view step and bail - context.ViewSteps.CreateStep(templateName, _contentType, content); - break; - } - } - } - - - } - } -} +// using System; +// using System.Collections.Generic; +// using System.IO; +// using Inversion.Data; +// using RazorEngine; +// using RazorEngine.Templating; + +// using Inversion.Process; +// using Inversion.Collections; + +// namespace Inversion.Web.Behaviour.View { + +// /// +// /// A web behaviour that resolves razor templates to generate views. +// /// +// /// +// /// +// /// Razor isn't getting a lot of attention in Inversion initially, at +// /// some point I'll pay it some attention, but it's really not a priority +// /// as personally I'm not a big fan. +// /// +// /// +// /// Razor is the fast food of templating. It's really tasting +// /// and super-saturated with utility, and it's bad for you. +// /// When rendering a view you really shouldn't be able to +// /// yield side-effects, and you shouldn't be able to consider +// /// anything other than the view you're rendering. In Razor +// /// you can do anything you want. And you will. Especially +// /// when people aren't looking. +// /// +// /// +// /// Worse, you'll start architecting clever helpers, and mappings, +// /// and... you'll start refactoring, and all your templates will +// /// become enmeshed in one glorious front-end monolith. +// /// +// /// +// /// Razor. Just say "no"... Okay, I'm over-egging it a bit. +// /// +// /// +// /// Joking aside, I get why Razor is so popular. It's simple, bendy, +// /// easy for .NET devs to dive into, and you can brute force yourself +// /// out of any situation. It does however in my view encourage +// /// poor practice and blurs an important application layer +// /// so the middle and front of the application risk becoming +// /// quickly enmeshed. +// /// +// /// +// /// Conclave favours XML/XSL, I understand why you +// /// might not, hence . +// /// +// /// +// public class RazorViewBehaviour : WebBehaviour { + +// private readonly string _contentType; + +// /// +// /// +// /// +// /// +// /// +// /// This constructor defaults the content type to `text/html`. +// /// +// public RazorViewBehaviour(string respondsTo) : this(respondsTo, "text/html") { } + +// /// +// /// +// /// +// /// +// /// +// public RazorViewBehaviour(string respondsTo, string contentType) +// : base(respondsTo) { +// _contentType = contentType; +// } + +// // TODO: confirm thread safe +// // The iterator generated for this should be +// // ThreadLocal and therefore safe to use +// // in this manner on a singleton, would be +// // nice to fonfirm this. +// private IEnumerable _possibleTemplates(IWebContext context) { +// string area = context.Params["area"]; +// string concern = context.Params["concern"]; +// string action = String.Format("{0}.cshtml", context.Params["action"]); + +// // area/concern/action +// yield return Path.Combine(area, concern, action); +// yield return Path.Combine(area, concern, "default.cshtml"); +// // area/action +// yield return Path.Combine(area, action); +// yield return Path.Combine(area, "default.cshtml"); +// // action +// yield return action; +// yield return "default.cshtml"; + +// } + +// /// +// /// Tranforms the last view-step using a razor template. +// /// +// /// The vent that was considered for this action. +// /// The context to act upon. +// public override void Action(IEvent ev, IWebContext context) { + +// if (context.ViewSteps.HasSteps && context.ViewSteps.Last.HasModel) { // we should have a model that we're going to render + +// DataDictionary viewState = context.ViewSteps.Last.Model as DataDictionary; + +// string content = String.Empty; // default output if we can't process a template + +// foreach (string templateName in _possibleTemplates(context)) { // check each possible template in turn +// // This is the most immediate way I found to check if a template has been compiled +// // but we don't actually use the returned template as I can't find how to get a razor context +// // to run against, when I do this code will probably chage with a possible early bail here. +// ITemplate compiledTemplate = Razor.Resolve(templateName); + +// bool compiled = false; +// if (compiledTemplate == null) { // we'll need to look for the template +// string templatePath = Path.Combine("Resources", "Views", "Razor", templateName); +// if (context.Resources.Exists(templatePath)) { +// string template = context.Resources.Open(templatePath).AsText(); +// Razor.Compile(template, viewState.GetType(), templateName); +// compiled = true; +// } else { +// continue; +// } +// } +// if (compiledTemplate != null || compiled) { +// content = Razor.Run(templateName, viewState); +// } + +// if (!String.IsNullOrEmpty(content)) { // we have content so create the view step and bail +// context.ViewSteps.CreateStep(templateName, _contentType, content); +// break; +// } +// } +// } + + +// } +// } +// } From be1c1cff32d2a87575e58e8102ca9dbe1f453a84 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Sat, 9 Dec 2017 15:41:22 +0000 Subject: [PATCH 03/29] fixes --- .../Properties/launchSettings.json | 27 ++ Inversion.Demo.Katana/Startup.cs | 4 +- .../Behaviour/View/RazorViewBehaviour.cs | 282 +++++++++--------- inversion-dev.sln | 98 +++--- 4 files changed, 227 insertions(+), 184 deletions(-) create mode 100644 Inversion.Demo.Katana/Properties/launchSettings.json diff --git a/Inversion.Demo.Katana/Properties/launchSettings.json b/Inversion.Demo.Katana/Properties/launchSettings.json new file mode 100644 index 0000000..d6838d0 --- /dev/null +++ b/Inversion.Demo.Katana/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:3057/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Inversion.Demo.Katana": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:3058/" + } + } +} \ No newline at end of file diff --git a/Inversion.Demo.Katana/Startup.cs b/Inversion.Demo.Katana/Startup.cs index d464317..6f70e3a 100644 --- a/Inversion.Demo.Katana/Startup.cs +++ b/Inversion.Demo.Katana/Startup.cs @@ -132,7 +132,7 @@ public AspNetCoreWebRequest(HttpContext context) public IRequestFilesCollection Files => throw new NotImplementedException(); // TODO: convert this less weird. The port is missing. - public UrlInfo UrlInfo => new UrlInfo(new Uri($"{this.context.Request.Protocol}://{this.context.Request.Host}/{this.context.Request.Path.Value}?{this.context.Request.QueryString}")); + public UrlInfo UrlInfo => new UrlInfo(new Uri($"{this.context.Request.Scheme}://{this.context.Request.Host}/{this.context.Request.Path.Value}?{this.context.Request.QueryString}")); public string Method => this.context.Request.Method; @@ -140,7 +140,7 @@ public AspNetCoreWebRequest(HttpContext context) public bool IsPost => this.Method.ToLower() == "post"; - public IDictionary Params => throw new NotImplementedException(); + public IDictionary Params => new Dictionary(this.context.Request.Query.Select(q => new KeyValuePair(q.Key, string.Join(",", q.Value)))); public string Payload => this.context.Request.Body.AsText(); diff --git a/Inversion.Web/Behaviour/View/RazorViewBehaviour.cs b/Inversion.Web/Behaviour/View/RazorViewBehaviour.cs index 50ee13a..36bd2dc 100644 --- a/Inversion.Web/Behaviour/View/RazorViewBehaviour.cs +++ b/Inversion.Web/Behaviour/View/RazorViewBehaviour.cs @@ -1,141 +1,141 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Inversion.Data; -using RazorEngine; -using RazorEngine.Templating; - -using Inversion.Process; -using Inversion.Collections; - -namespace Inversion.Web.Behaviour.View { - - /// - /// A web behaviour that resolves razor templates to generate views. - /// - /// - /// - /// Razor isn't getting a lot of attention in Inversion initially, at - /// some point I'll pay it some attention, but it's really not a priority - /// as personally I'm not a big fan. - /// - /// - /// Razor is the fast food of templating. It's really tasting - /// and super-saturated with utility, and it's bad for you. - /// When rendering a view you really shouldn't be able to - /// yield side-effects, and you shouldn't be able to consider - /// anything other than the view you're rendering. In Razor - /// you can do anything you want. And you will. Especially - /// when people aren't looking. - /// - /// - /// Worse, you'll start architecting clever helpers, and mappings, - /// and... you'll start refactoring, and all your templates will - /// become enmeshed in one glorious front-end monolith. - /// - /// - /// Razor. Just say "no"... Okay, I'm over-egging it a bit. - /// - /// - /// Joking aside, I get why Razor is so popular. It's simple, bendy, - /// easy for .NET devs to dive into, and you can brute force yourself - /// out of any situation. It does however in my view encourage - /// poor practice and blurs an important application layer - /// so the middle and front of the application risk becoming - /// quickly enmeshed. - /// - /// - /// Conclave favours XML/XSL, I understand why you - /// might not, hence . - /// - /// - public class RazorViewBehaviour : WebBehaviour { - - private readonly string _contentType; - - /// - /// - /// - /// - /// - /// This constructor defaults the content type to `text/html`. - /// - public RazorViewBehaviour(string respondsTo) : this(respondsTo, "text/html") { } - - /// - /// - /// - /// - /// - public RazorViewBehaviour(string respondsTo, string contentType) - : base(respondsTo) { - _contentType = contentType; - } - - // TODO: confirm thread safe - // The iterator generated for this should be - // ThreadLocal and therefore safe to use - // in this manner on a singleton, would be - // nice to fonfirm this. - private IEnumerable _possibleTemplates(IWebContext context) { - string area = context.Params["area"]; - string concern = context.Params["concern"]; - string action = String.Format("{0}.cshtml", context.Params["action"]); - - // area/concern/action - yield return Path.Combine(area, concern, action); - yield return Path.Combine(area, concern, "default.cshtml"); - // area/action - yield return Path.Combine(area, action); - yield return Path.Combine(area, "default.cshtml"); - // action - yield return action; - yield return "default.cshtml"; - - } - - /// - /// Tranforms the last view-step using a razor template. - /// - /// The vent that was considered for this action. - /// The context to act upon. - public override void Action(IEvent ev, IWebContext context) { - - if (context.ViewSteps.HasSteps && context.ViewSteps.Last.HasModel) { // we should have a model that we're going to render - - DataDictionary viewState = context.ViewSteps.Last.Model as DataDictionary; - - string content = String.Empty; // default output if we can't process a template - - foreach (string templateName in _possibleTemplates(context)) { // check each possible template in turn - // This is the most immediate way I found to check if a template has been compiled - // but we don't actually use the returned template as I can't find how to get a razor context - // to run against, when I do this code will probably chage with a possible early bail here. - ITemplate compiledTemplate = Razor.Resolve(templateName); - - bool compiled = false; - if (compiledTemplate == null) { // we'll need to look for the template - string templatePath = Path.Combine("Resources", "Views", "Razor", templateName); - if (context.Resources.Exists(templatePath)) { - string template = context.Resources.Open(templatePath).AsText(); - Razor.Compile(template, viewState.GetType(), templateName); - compiled = true; - } else { - continue; - } - } - if (compiledTemplate != null || compiled) { - content = Razor.Run(templateName, viewState); - } - - if (!String.IsNullOrEmpty(content)) { // we have content so create the view step and bail - context.ViewSteps.CreateStep(templateName, _contentType, content); - break; - } - } - } - - - } - } -} +//using System; +//using System.Collections.Generic; +//using System.IO; +//using Inversion.Data; +//using RazorEngine; +//using RazorEngine.Templating; + +//using Inversion.Process; +//using Inversion.Collections; + +//namespace Inversion.Web.Behaviour.View { + +// /// +// /// A web behaviour that resolves razor templates to generate views. +// /// +// /// +// /// +// /// Razor isn't getting a lot of attention in Inversion initially, at +// /// some point I'll pay it some attention, but it's really not a priority +// /// as personally I'm not a big fan. +// /// +// /// +// /// Razor is the fast food of templating. It's really tasting +// /// and super-saturated with utility, and it's bad for you. +// /// When rendering a view you really shouldn't be able to +// /// yield side-effects, and you shouldn't be able to consider +// /// anything other than the view you're rendering. In Razor +// /// you can do anything you want. And you will. Especially +// /// when people aren't looking. +// /// +// /// +// /// Worse, you'll start architecting clever helpers, and mappings, +// /// and... you'll start refactoring, and all your templates will +// /// become enmeshed in one glorious front-end monolith. +// /// +// /// +// /// Razor. Just say "no"... Okay, I'm over-egging it a bit. +// /// +// /// +// /// Joking aside, I get why Razor is so popular. It's simple, bendy, +// /// easy for .NET devs to dive into, and you can brute force yourself +// /// out of any situation. It does however in my view encourage +// /// poor practice and blurs an important application layer +// /// so the middle and front of the application risk becoming +// /// quickly enmeshed. +// /// +// /// +// /// Conclave favours XML/XSL, I understand why you +// /// might not, hence . +// /// +// /// +// public class RazorViewBehaviour : WebBehaviour { + +// private readonly string _contentType; + +// /// +// /// +// /// +// /// +// /// +// /// This constructor defaults the content type to `text/html`. +// /// +// public RazorViewBehaviour(string respondsTo) : this(respondsTo, "text/html") { } + +// /// +// /// +// /// +// /// +// /// +// public RazorViewBehaviour(string respondsTo, string contentType) +// : base(respondsTo) { +// _contentType = contentType; +// } + +// // TODO: confirm thread safe +// // The iterator generated for this should be +// // ThreadLocal and therefore safe to use +// // in this manner on a singleton, would be +// // nice to fonfirm this. +// private IEnumerable _possibleTemplates(IWebContext context) { +// string area = context.Params["area"]; +// string concern = context.Params["concern"]; +// string action = String.Format("{0}.cshtml", context.Params["action"]); + +// // area/concern/action +// yield return Path.Combine(area, concern, action); +// yield return Path.Combine(area, concern, "default.cshtml"); +// // area/action +// yield return Path.Combine(area, action); +// yield return Path.Combine(area, "default.cshtml"); +// // action +// yield return action; +// yield return "default.cshtml"; + +// } + +// /// +// /// Tranforms the last view-step using a razor template. +// /// +// /// The vent that was considered for this action. +// /// The context to act upon. +// public override void Action(IEvent ev, IWebContext context) { + +// if (context.ViewSteps.HasSteps && context.ViewSteps.Last.HasModel) { // we should have a model that we're going to render + +// DataDictionary viewState = context.ViewSteps.Last.Model as DataDictionary; + +// string content = String.Empty; // default output if we can't process a template + +// foreach (string templateName in _possibleTemplates(context)) { // check each possible template in turn +// // This is the most immediate way I found to check if a template has been compiled +// // but we don't actually use the returned template as I can't find how to get a razor context +// // to run against, when I do this code will probably chage with a possible early bail here. +// ITemplate compiledTemplate = Razor.Resolve(templateName); + +// bool compiled = false; +// if (compiledTemplate == null) { // we'll need to look for the template +// string templatePath = Path.Combine("Resources", "Views", "Razor", templateName); +// if (context.Resources.Exists(templatePath)) { +// string template = context.Resources.Open(templatePath).AsText(); +// Razor.Compile(template, viewState.GetType(), templateName); +// compiled = true; +// } else { +// continue; +// } +// } +// if (compiledTemplate != null || compiled) { +// content = Razor.Run(templateName, viewState); +// } + +// if (!String.IsNullOrEmpty(content)) { // we have content so create the view step and bail +// context.ViewSteps.CreateStep(templateName, _contentType, content); +// break; +// } +// } +// } + + +// } +// } +//} diff --git a/inversion-dev.sln b/inversion-dev.sln index 4ebbfd9..01ab7c4 100644 --- a/inversion-dev.sln +++ b/inversion-dev.sln @@ -1,15 +1,16 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 +VisualStudioVersion = 15.0.27130.2003 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Demo.Katana", "Inversion.Demo.Katana\Inversion.Demo.Katana.csproj", "{02A7C04D-3A85-4839-BD60-13AB63367A04}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Inversion.Demo.Katana", "Inversion.Demo.Katana\Inversion.Demo.Katana.csproj", "{02A7C04D-3A85-4839-BD60-13AB63367A04}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Process", "Inversion.Process\Inversion.Process.csproj", "{33017658-0806-43CB-B73A-41DEAF4499AB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Inversion.Process", "Inversion.Process\Inversion.Process.csproj", "{33017658-0806-43CB-B73A-41DEAF4499AB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion", "Inversion\Inversion.csproj", "{523D340C-59E7-424D-BC67-B663744203ED}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Inversion", "Inversion\Inversion.csproj", "{523D340C-59E7-424D-BC67-B663744203ED}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inversion.Web", "Inversion.Web\Inversion.Web.csproj", "{F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Inversion.Web", "Inversion.Web\Inversion.Web.csproj", "{F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Inversion.Naiad", "Inversion.Naiad\Inversion.Naiad.csproj", "{7F0FAE53-557D-4567-8289-CD1B17BDC4D8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -20,57 +21,72 @@ Global Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|Any CPU.Build.0 = Debug|Any CPU - {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x64.ActiveCfg = Debug|x64 - {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x64.Build.0 = Debug|x64 - {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x86.ActiveCfg = Debug|x86 - {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x86.Build.0 = Debug|x86 + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x64.ActiveCfg = Debug|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x64.Build.0 = Debug|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x86.ActiveCfg = Debug|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Debug|x86.Build.0 = Debug|Any CPU {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|Any CPU.ActiveCfg = Release|Any CPU {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|Any CPU.Build.0 = Release|Any CPU - {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x64.ActiveCfg = Release|x64 - {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x64.Build.0 = Release|x64 - {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x86.ActiveCfg = Release|x86 - {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x86.Build.0 = Release|x86 + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x64.ActiveCfg = Release|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x64.Build.0 = Release|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x86.ActiveCfg = Release|Any CPU + {02A7C04D-3A85-4839-BD60-13AB63367A04}.Release|x86.Build.0 = Release|Any CPU {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x64.ActiveCfg = Debug|x64 - {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x64.Build.0 = Debug|x64 - {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x86.ActiveCfg = Debug|x86 - {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x86.Build.0 = Debug|x86 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x64.ActiveCfg = Debug|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x64.Build.0 = Debug|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x86.ActiveCfg = Debug|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Debug|x86.Build.0 = Debug|Any CPU {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|Any CPU.ActiveCfg = Release|Any CPU {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|Any CPU.Build.0 = Release|Any CPU - {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x64.ActiveCfg = Release|x64 - {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x64.Build.0 = Release|x64 - {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x86.ActiveCfg = Release|x86 - {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x86.Build.0 = Release|x86 + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x64.ActiveCfg = Release|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x64.Build.0 = Release|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x86.ActiveCfg = Release|Any CPU + {33017658-0806-43CB-B73A-41DEAF4499AB}.Release|x86.Build.0 = Release|Any CPU {523D340C-59E7-424D-BC67-B663744203ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {523D340C-59E7-424D-BC67-B663744203ED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x64.ActiveCfg = Debug|x64 - {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x64.Build.0 = Debug|x64 - {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x86.ActiveCfg = Debug|x86 - {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x86.Build.0 = Debug|x86 + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x64.ActiveCfg = Debug|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x64.Build.0 = Debug|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x86.ActiveCfg = Debug|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Debug|x86.Build.0 = Debug|Any CPU {523D340C-59E7-424D-BC67-B663744203ED}.Release|Any CPU.ActiveCfg = Release|Any CPU {523D340C-59E7-424D-BC67-B663744203ED}.Release|Any CPU.Build.0 = Release|Any CPU - {523D340C-59E7-424D-BC67-B663744203ED}.Release|x64.ActiveCfg = Release|x64 - {523D340C-59E7-424D-BC67-B663744203ED}.Release|x64.Build.0 = Release|x64 - {523D340C-59E7-424D-BC67-B663744203ED}.Release|x86.ActiveCfg = Release|x86 - {523D340C-59E7-424D-BC67-B663744203ED}.Release|x86.Build.0 = Release|x86 + {523D340C-59E7-424D-BC67-B663744203ED}.Release|x64.ActiveCfg = Release|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Release|x64.Build.0 = Release|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Release|x86.ActiveCfg = Release|Any CPU + {523D340C-59E7-424D-BC67-B663744203ED}.Release|x86.Build.0 = Release|Any CPU {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x64.ActiveCfg = Debug|x64 - {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x64.Build.0 = Debug|x64 - {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x86.ActiveCfg = Debug|x86 - {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x86.Build.0 = Debug|x86 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x64.ActiveCfg = Debug|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x64.Build.0 = Debug|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x86.ActiveCfg = Debug|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Debug|x86.Build.0 = Debug|Any CPU {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|Any CPU.ActiveCfg = Release|Any CPU {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|Any CPU.Build.0 = Release|Any CPU - {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x64.ActiveCfg = Release|x64 - {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x64.Build.0 = Release|x64 - {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x86.ActiveCfg = Release|x86 - {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x86.Build.0 = Release|x86 + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x64.ActiveCfg = Release|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x64.Build.0 = Release|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x86.ActiveCfg = Release|Any CPU + {F8AF201C-38BB-4B54-BFAD-7AA0846FE9DF}.Release|x86.Build.0 = Release|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Debug|x64.ActiveCfg = Debug|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Debug|x64.Build.0 = Debug|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Debug|x86.ActiveCfg = Debug|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Debug|x86.Build.0 = Debug|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Release|Any CPU.Build.0 = Release|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Release|x64.ActiveCfg = Release|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Release|x64.Build.0 = Release|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Release|x86.ActiveCfg = Release|Any CPU + {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FDB9E04B-CD16-49FE-A08E-C81D02FB1C97} EndGlobalSection EndGlobal From 82834259c7c323456235250ff08d835e8e4cd086 Mon Sep 17 00:00:00 2001 From: Robert Stiff Date: Sat, 9 Dec 2017 16:18:18 +0000 Subject: [PATCH 04/29] Swap in the new MemoryCache for cross platform support. --- Inversion.Process/IProcessContext.cs | 4 ++-- Inversion.Process/Inversion.Process.csproj | 2 +- Inversion.Process/ProcessContext.cs | 8 +++++--- Inversion.Process/SimpleProcessContext.cs | 8 +++++--- Inversion.Process/SynchronizedProcessContext.cs | 8 +++++--- .../Behaviour/View/XsltViewBehaviour.cs | 16 ++++++++++------ Inversion.Web/Inversion.Web.csproj | 1 + 7 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Inversion.Process/IProcessContext.cs b/Inversion.Process/IProcessContext.cs index 4909d07..98cbbb2 100644 --- a/Inversion.Process/IProcessContext.cs +++ b/Inversion.Process/IProcessContext.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using System.Runtime.Caching; using Inversion.Collections; using Inversion.Data; using Inversion.Process.Behaviour; +using Microsoft.Extensions.Caching.Memory; namespace Inversion.Process { /// @@ -35,7 +35,7 @@ public interface IProcessContext : IDisposable { /// This really needs replaced with our own interface /// that we control. This isn't portable. /// - ObjectCache ObjectCache { get; } + IMemoryCache ObjectCache { get; } /// /// Messages intended for user feedback. diff --git a/Inversion.Process/Inversion.Process.csproj b/Inversion.Process/Inversion.Process.csproj index 1d0e0d4..2317aae 100644 --- a/Inversion.Process/Inversion.Process.csproj +++ b/Inversion.Process/Inversion.Process.csproj @@ -6,8 +6,8 @@ netstandard2.0 + - \ No newline at end of file diff --git a/Inversion.Process/ProcessContext.cs b/Inversion.Process/ProcessContext.cs index d3412f6..07c7500 100644 --- a/Inversion.Process/ProcessContext.cs +++ b/Inversion.Process/ProcessContext.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using System.Reactive.Subjects; using System.Reactive.Linq; -using System.Runtime.Caching; using System.Text; using System.Threading; using Inversion.Collections; using Inversion.Data; using Inversion.Process.Behaviour; +using Microsoft.Extensions.Caching.Memory; namespace Inversion.Process { @@ -68,7 +68,7 @@ protected ISubject Bus { /// This really needs replaced with our own interface /// that we control. This isn't portable. /// - public ObjectCache ObjectCache { + public IMemoryCache ObjectCache { get { return _cache; } } @@ -152,7 +152,9 @@ public IDataDictionary Params { public ProcessContext(IServiceContainer services, IResourceAdapter resources) { _serviceContainer = services; _resources = resources; - _cache = MemoryCache.Default; + _cache = new MemoryCache(new MemoryCacheOptions { + + }); _bus = new Subject(); _messages = new DataCollection(); _errors = new DataCollection(); diff --git a/Inversion.Process/SimpleProcessContext.cs b/Inversion.Process/SimpleProcessContext.cs index a7ab8bb..68c41ca 100644 --- a/Inversion.Process/SimpleProcessContext.cs +++ b/Inversion.Process/SimpleProcessContext.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.Caching; using System.Text; using System.Threading; using Inversion.Collections; using Inversion.Data; using Inversion.Process.Behaviour; +using Microsoft.Extensions.Caching.Memory; namespace Inversion.Process { @@ -68,7 +68,7 @@ protected IEnumerable Bus { /// This really needs replaced with our own interface /// that we control. This isn't portable. /// - public ObjectCache ObjectCache { + public IMemoryCache ObjectCache { get { return _cache; } } @@ -152,7 +152,9 @@ public IDataDictionary Params { public SimpleProcessContext(IServiceContainer services, IResourceAdapter resources) { _serviceContainer = services; _resources = resources; - _cache = MemoryCache.Default; + _cache = new MemoryCache(new MemoryCacheOptions { + + }); //_bus = new Subject(); _bus = new HashSet(); _messages = new DataCollection(); diff --git a/Inversion.Process/SynchronizedProcessContext.cs b/Inversion.Process/SynchronizedProcessContext.cs index 3764abb..c35ab01 100644 --- a/Inversion.Process/SynchronizedProcessContext.cs +++ b/Inversion.Process/SynchronizedProcessContext.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using System.Reactive.Subjects; using System.Reactive.Linq; -using System.Runtime.Caching; using System.Text; using System.Threading; using Inversion.Collections; using Inversion.Data; using Inversion.Process.Behaviour; +using Microsoft.Extensions.Caching.Memory; namespace Inversion.Process { @@ -70,7 +70,7 @@ protected ISubject Bus { /// This really needs replaced with our own interface /// that we control. This isn't portable. /// - public ObjectCache ObjectCache { + public IMemoryCache ObjectCache { get { return _cache; } } @@ -152,7 +152,9 @@ public IDataDictionary Params { public SynchronizedProcessContext(IServiceContainer services, IResourceAdapter resources) { _serviceContainer = services; _resources = resources; - _cache = MemoryCache.Default; + _cache = new MemoryCache(new MemoryCacheOptions { + + }); _bus = Subject.Synchronize(new Subject()); _messages = new ConcurrentDataCollection(); _errors = new ConcurrentDataCollection(); diff --git a/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs b/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs index 9495323..b8efad2 100644 --- a/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs +++ b/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Runtime.Caching; using System.Text; using System.Xml; using System.Xml.Xsl; @@ -154,7 +153,14 @@ public override void Action(IEvent ev, IProcessContext context) { // check if we have the template cached string cacheKey = String.Concat("xsl::", templateName); - XslCompiledTransform xsl = (!_enableCache || context.IsFlagged("nocache")) ? null : context.ObjectCache.Get(cacheKey) as XslCompiledTransform; + XslCompiledTransform xsl = null; + + if ( _enableCache && !context.IsFlagged("nocache") ) { + object cacheEntry = null; + context.ObjectCache.TryGetValue(cacheKey, out cacheEntry); + xsl = cacheEntry as XslCompiledTransform; + } + if (xsl == null) { // we dont have it cached // does the file exist? @@ -162,10 +168,8 @@ public override void Action(IEvent ev, IProcessContext context) { if (context.Resources.Exists(templatePath)){ xsl = context.Resources.Open(templatePath).AsXslDocument(); if (_enableCache) { - CacheItemPolicy policy = new CacheItemPolicy { - AbsoluteExpiration = ObjectCache.InfiniteAbsoluteExpiration - }; - context.ObjectCache.Add(cacheKey, xsl, policy); + var cacheEntry = context.ObjectCache.CreateEntry(cacheKey); + cacheEntry.Value = xsl; } } } diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index c26c375..328e075 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -2,6 +2,7 @@ + From d97b7d4ad3a8ec6b7e25312956a323acafde6b1b Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Sat, 9 Dec 2017 17:17:20 +0000 Subject: [PATCH 05/29] working pipeline! --- Inversion.Demo.Katana/Startup.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Inversion.Demo.Katana/Startup.cs b/Inversion.Demo.Katana/Startup.cs index 6f70e3a..8717b83 100644 --- a/Inversion.Demo.Katana/Startup.cs +++ b/Inversion.Demo.Katana/Startup.cs @@ -160,7 +160,7 @@ public AspNetCoreWebResponse(HttpContext context) this.context = context; } - public TextWriter Output => new StreamWriter(this.OutputStream); + public TextWriter Output => throw new NotImplementedException(); public Stream OutputStream => this.context.Response.Body; @@ -186,7 +186,7 @@ public string StatusDescription { /// Flushes the response steam and ends the response. /// public void End() { - // nothing to do on an OWIN implementation that is apparent to me at this point. + // nothing to do on an OWIN implementation that is apparent to me at this point. } /// @@ -194,7 +194,7 @@ public void End() { /// /// The text to write to the response stream. public void Write(string text) { - this.Output.Write(text); + this.context.Response.WriteAsync(text).Wait(); } /// @@ -203,7 +203,7 @@ public void Write(string text) { /// The text to write to the response stream. /// The arguments to interpolate into the text. public void WriteFormat(string text, params object[] args) { - this.Output.Write(string.Format(text, args)); + this.context.Response.WriteAsync(string.Format(text, args)).Wait(); } /// From 9040174ccb5b6bd0d22e6ba6778295c2ff009569 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Sat, 9 Dec 2017 17:29:55 +0000 Subject: [PATCH 06/29] travisty. --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f3dc57b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: csharp +dotnet: 2.0.0 +mono: none +solution: dlcs-prototype.sln +dist: trusty + From 422050989d735e522bba28c20d282ab40d802697 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Sat, 9 Dec 2017 17:31:04 +0000 Subject: [PATCH 07/29] travis script. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index f3dc57b..ee3c0a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,7 @@ dotnet: 2.0.0 mono: none solution: dlcs-prototype.sln dist: trusty +script: + - dotnet restore + - dotnet build From b996a1d5d87c32f39a17fb2509ac8bbb613d331d Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Fri, 23 Feb 2018 23:56:18 +0000 Subject: [PATCH 08/29] ignore .vscode folder. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d1fa4b3..cdda339 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ _ReSharper*/ !packages/repositories.config /export/ .vs/ +.vscode/ From 11a2da5725d9738c3aed06b048c3bd957812b177 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Fri, 23 Feb 2018 23:57:13 +0000 Subject: [PATCH 09/29] adding aspnetcore support. --- Inversion.Naiad/Inversion.Naiad.csproj | 11 ++- Inversion.Process/Inversion.Process.csproj | 7 +- Inversion.Web.AspNetCore/AspNetCoreContext.cs | 32 +++++++ .../AspNetCoreWebRequest.cs | 44 +++++++++ .../AspNetCoreWebResponse.cs | 89 +++++++++++++++++++ .../Inversion.Web.AspNetCore.csproj | 19 ++++ Inversion.Web/Inversion.Web.csproj | 5 +- Inversion/Inversion.csproj | 3 + 8 files changed, 202 insertions(+), 8 deletions(-) create mode 100644 Inversion.Web.AspNetCore/AspNetCoreContext.cs create mode 100644 Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs create mode 100644 Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs create mode 100644 Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj diff --git a/Inversion.Naiad/Inversion.Naiad.csproj b/Inversion.Naiad/Inversion.Naiad.csproj index c26c375..72428f1 100644 --- a/Inversion.Naiad/Inversion.Naiad.csproj +++ b/Inversion.Naiad/Inversion.Naiad.csproj @@ -1,11 +1,14 @@ - - - - netstandard2.0 + Inversion.Naiad + 1.0.3 + Guy Murphy + + + + diff --git a/Inversion.Process/Inversion.Process.csproj b/Inversion.Process/Inversion.Process.csproj index 2317aae..8b83c74 100644 --- a/Inversion.Process/Inversion.Process.csproj +++ b/Inversion.Process/Inversion.Process.csproj @@ -1,13 +1,14 @@ - - - netstandard2.0 + Inversion.Process + 1.0.3 + Guy Murphy + \ No newline at end of file diff --git a/Inversion.Web.AspNetCore/AspNetCoreContext.cs b/Inversion.Web.AspNetCore/AspNetCoreContext.cs new file mode 100644 index 0000000..6acefd1 --- /dev/null +++ b/Inversion.Web.AspNetCore/AspNetCoreContext.cs @@ -0,0 +1,32 @@ +using System; +using System.Security.Principal; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Http; + +using Inversion.Process; +using Inversion.Web; +using Inversion.Naiad; +using Inversion.Data; + +namespace Inversion.Web.AspNetCore +{ + public class AspNetCoreContext : ProcessContext, IWebContext + { + public IWebApplication Application => throw new NotImplementedException(); + + public IWebResponse Response => new AspNetCoreWebResponse(this.context); + + public IWebRequest Request => new AspNetCoreWebRequest(this.context); + + public IPrincipal User { get => this.context.User; set => throw new NotImplementedException(); } + + + private HttpContext context; + + public AspNetCoreContext(HttpContext context, ServiceContainer services, FileSystemResourceAdapter resources) + : base(services, resources) + { + this.context = context; + } + } +} diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs new file mode 100644 index 0000000..35d2218 --- /dev/null +++ b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using System.Security.Principal; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Http; + +using Inversion.Data; +using Inversion.Web; + +namespace Inversion.Web.AspNetCore +{ + public class AspNetCoreWebRequest : IWebRequest + { + private HttpContext context; + + public AspNetCoreWebRequest(HttpContext context) + { + this.context = context; + } + + public IRequestFilesCollection Files => throw new NotImplementedException(); + + // TODO: convert this less weird. The port is missing. + public UrlInfo UrlInfo => new UrlInfo(new Uri($"{this.context.Request.Scheme}://{this.context.Request.Host}/{this.context.Request.Path.Value}?{this.context.Request.QueryString}")); + + public string Method => this.context.Request.Method; + + public bool IsGet => this.Method.ToLower() == "get"; + + public bool IsPost => this.Method.ToLower() == "post"; + + public IDictionary Params => new Dictionary(this.context.Request.Query.Select(q => new KeyValuePair(q.Key, string.Join(",", q.Value)))); + + public string Payload => this.context.Request.Body.AsText(); + + public IEnumerable Flags => this.context.Request.Query.Where(x => string.IsNullOrEmpty(x.Value)).Select(x => x.Key); + + public IDictionary Headers => this.context.Request.Headers.ToDictionary(x => x.Key, x => string.Join(",", x.Value)); + + public Web.IRequestCookieCollection Cookies => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs b/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs new file mode 100644 index 0000000..a9ac7bd --- /dev/null +++ b/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +using System.Security.Principal; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Http; + +using Inversion.Process; +using Inversion.Web; + +namespace Inversion.Web.AspNetCore +{ + public class AspNetCoreWebResponse : IWebResponse + { + private HttpContext context; + + public AspNetCoreWebResponse(HttpContext context) + { + this.context = context; + } + + public TextWriter Output => throw new NotImplementedException(); + + public Stream OutputStream => this.context.Response.Body; + + public int StatusCode { get => this.context.Response.StatusCode; set => this.context.Response.StatusCode = value; } + public string StatusDescription { + get + { + return context.Response.HttpContext.Features.Get().ReasonPhrase; + } + set + { + context.Response.HttpContext.Features.Get().ReasonPhrase = value; + } + } + + public string ContentType { get => this.context.Response.ContentType; set => this.context.Response.ContentType = value; } + + public IResponseCookieCollection Cookies => throw new NotImplementedException(); + + public IResponseHeaderCollection Headers => throw new NotImplementedException(); + + /// + /// Flushes the response steam and ends the response. + /// + public void End() { + // nothing to do on an OWIN implementation that is apparent to me at this point. + } + + /// + /// Writes the provided text to the response stream. + /// + /// The text to write to the response stream. + public void Write(string text) { + this.context.Response.WriteAsync(text).Wait(); + } + + /// + /// Writes the provided formatted text to the response stream. + /// + /// The text to write to the response stream. + /// The arguments to interpolate into the text. + public void WriteFormat(string text, params object[] args) { + this.context.Response.WriteAsync(string.Format(text, args)).Wait(); + } + + /// + /// Redirects the request to the provided url. + /// + /// The url to redirect to. + public void Redirect(string url) { + this.context.Response.Redirect(url); + } + + /// + /// Redirects the request permanently to the provided url + /// issuing a `301` in the response. + /// + /// + public void PermanentRedirect(string url) { + this.StatusCode = 301; + this.StatusDescription = "301 Moved Permanently"; + this.context.Response.Headers.Append("Location", url); + } + } +} \ No newline at end of file diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj new file mode 100644 index 0000000..f5d828e --- /dev/null +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -0,0 +1,19 @@ + + + + netcoreapp2.0 + Inversion.Web.AspNetCore + 1.0.3 + Adam Christie + + + + + + + + + + + + diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index 328e075..7aa49bf 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -1,12 +1,15 @@ - + netstandard2.0 + Inversion.Web + 1.0.3 + Guy Murphy diff --git a/Inversion/Inversion.csproj b/Inversion/Inversion.csproj index 60eefdf..658b579 100644 --- a/Inversion/Inversion.csproj +++ b/Inversion/Inversion.csproj @@ -1,6 +1,9 @@ netstandard2.0 + Inversion + 1.0.2 + Guy Murphy From ad73a8ec6f1cbec290d9a91f05df58d6067ee317 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Sat, 24 Feb 2018 09:54:24 +0000 Subject: [PATCH 10/29] refining nuget treatment. --- Inversion.Demo.Katana/Inversion.Demo.Katana.csproj | 11 ++++------- Inversion.Naiad/Inversion.Naiad.csproj | 4 ++-- Inversion.Process/Inversion.Process.csproj | 4 ++-- Inversion.Process/packages.config | 10 ---------- .../Inversion.Web.AspNetCore.csproj | 10 +++++----- Inversion.Web/Inversion.Web.csproj | 12 ++++++------ Inversion/Inversion.csproj | 2 +- Inversion/packages.config | 4 ---- 8 files changed, 20 insertions(+), 37 deletions(-) delete mode 100644 Inversion.Process/packages.config delete mode 100644 Inversion/packages.config diff --git a/Inversion.Demo.Katana/Inversion.Demo.Katana.csproj b/Inversion.Demo.Katana/Inversion.Demo.Katana.csproj index 8e70810..0da2aee 100644 --- a/Inversion.Demo.Katana/Inversion.Demo.Katana.csproj +++ b/Inversion.Demo.Katana/Inversion.Demo.Katana.csproj @@ -11,13 +11,10 @@ - - - - - - - + + + + diff --git a/Inversion.Naiad/Inversion.Naiad.csproj b/Inversion.Naiad/Inversion.Naiad.csproj index 72428f1..e65fb77 100644 --- a/Inversion.Naiad/Inversion.Naiad.csproj +++ b/Inversion.Naiad/Inversion.Naiad.csproj @@ -3,12 +3,12 @@ netstandard2.0 Inversion.Naiad - 1.0.3 + 1.0.4 Guy Murphy - + diff --git a/Inversion.Process/Inversion.Process.csproj b/Inversion.Process/Inversion.Process.csproj index 8b83c74..7ee69e6 100644 --- a/Inversion.Process/Inversion.Process.csproj +++ b/Inversion.Process/Inversion.Process.csproj @@ -2,13 +2,13 @@ netstandard2.0 Inversion.Process - 1.0.3 + 1.0.4 Guy Murphy - + \ No newline at end of file diff --git a/Inversion.Process/packages.config b/Inversion.Process/packages.config deleted file mode 100644 index 16559f2..0000000 --- a/Inversion.Process/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj index f5d828e..6d63308 100644 --- a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -3,17 +3,17 @@ netcoreapp2.0 Inversion.Web.AspNetCore - 1.0.3 + 1.0.4 Adam Christie - - - - + + + + diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index 7aa49bf..821b607 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -1,15 +1,15 @@ - - - - - netstandard2.0 Inversion.Web - 1.0.3 + 1.0.4 Guy Murphy + + + + + diff --git a/Inversion/Inversion.csproj b/Inversion/Inversion.csproj index 658b579..ad74261 100644 --- a/Inversion/Inversion.csproj +++ b/Inversion/Inversion.csproj @@ -2,7 +2,7 @@ netstandard2.0 Inversion - 1.0.2 + 1.0.3 Guy Murphy diff --git a/Inversion/packages.config b/Inversion/packages.config deleted file mode 100644 index 747efc5..0000000 --- a/Inversion/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From ebc595e661af9b93d5078f84d4315de59e000282 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Sun, 4 Mar 2018 10:30:24 +0000 Subject: [PATCH 11/29] moving to wildcards for references. removing some project items. --- .../Properties/launchSettings.json | 27 ------------------- Inversion.Demo.Katana/packages.config | 9 ------- Inversion.Naiad/Inversion.Naiad.csproj | 4 +-- Inversion.Process/Inversion.Process.csproj | 4 +-- .../Inversion.Web.AspNetCore.csproj | 12 ++++----- Inversion.Web/Inversion.Web.csproj | 4 +-- 6 files changed, 12 insertions(+), 48 deletions(-) delete mode 100644 Inversion.Demo.Katana/Properties/launchSettings.json delete mode 100644 Inversion.Demo.Katana/packages.config diff --git a/Inversion.Demo.Katana/Properties/launchSettings.json b/Inversion.Demo.Katana/Properties/launchSettings.json deleted file mode 100644 index d6838d0..0000000 --- a/Inversion.Demo.Katana/Properties/launchSettings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:3057/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Inversion.Demo.Katana": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:3058/" - } - } -} \ No newline at end of file diff --git a/Inversion.Demo.Katana/packages.config b/Inversion.Demo.Katana/packages.config deleted file mode 100644 index 67bc9c2..0000000 --- a/Inversion.Demo.Katana/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Inversion.Naiad/Inversion.Naiad.csproj b/Inversion.Naiad/Inversion.Naiad.csproj index e65fb77..00027fc 100644 --- a/Inversion.Naiad/Inversion.Naiad.csproj +++ b/Inversion.Naiad/Inversion.Naiad.csproj @@ -3,12 +3,12 @@ netstandard2.0 Inversion.Naiad - 1.0.4 + 1.0.5 Guy Murphy - + diff --git a/Inversion.Process/Inversion.Process.csproj b/Inversion.Process/Inversion.Process.csproj index 7ee69e6..fbe170f 100644 --- a/Inversion.Process/Inversion.Process.csproj +++ b/Inversion.Process/Inversion.Process.csproj @@ -2,13 +2,13 @@ netstandard2.0 Inversion.Process - 1.0.4 + 1.0.5 Guy Murphy - + \ No newline at end of file diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj index 6d63308..7c54b3e 100644 --- a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -3,17 +3,17 @@ netcoreapp2.0 Inversion.Web.AspNetCore - 1.0.4 + 1.0.5 Adam Christie - - - - - + + + + + diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index 821b607..362ec4b 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -3,12 +3,12 @@ netstandard2.0 Inversion.Web - 1.0.4 + 1.0.5 Guy Murphy - + From 69c5b7b5bc9ac8727b6bedda9e96150945bad87e Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Sun, 4 Mar 2018 10:44:23 +0000 Subject: [PATCH 12/29] minor update to travis file. --- .travis.yml | 10 +++++----- harp | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 harp diff --git a/.travis.yml b/.travis.yml index ee3c0a2..0ce169b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: csharp -dotnet: 2.0.0 mono: none -solution: dlcs-prototype.sln -dist: trusty -script: +dotnet: 2.0.0 + +install: - dotnet restore - - dotnet build +script: + - dotnet build diff --git a/harp b/harp new file mode 100644 index 0000000..ea80cb3 --- /dev/null +++ b/harp @@ -0,0 +1,19 @@ +diff --git a/.travis.yml b/.travis.yml +index ee3c0a2..0ce169b 100644 +--- a/.travis.yml ++++ b/.travis.yml +@@ -1,9 +1,9 @@ + language: csharp +-dotnet: 2.0.0 + mono: none +-solution: dlcs-prototype.sln +-dist: trusty +-script: ++dotnet: 2.0.0 ++ ++install: + - dotnet restore +- - dotnet build +  ++script: ++ - dotnet build From 541abc39ee541f0610d31b04c83fed7fcb54fc8a Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Tue, 6 Mar 2018 17:39:34 +0000 Subject: [PATCH 13/29] hinting at service container problems. --- Inversion.Naiad/Inversion.Naiad.csproj | 2 +- Inversion.Naiad/ServiceContainer.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Inversion.Naiad/Inversion.Naiad.csproj b/Inversion.Naiad/Inversion.Naiad.csproj index 00027fc..2b293b7 100644 --- a/Inversion.Naiad/Inversion.Naiad.csproj +++ b/Inversion.Naiad/Inversion.Naiad.csproj @@ -3,7 +3,7 @@ netstandard2.0 Inversion.Naiad - 1.0.5 + 1.0.6 Guy Murphy diff --git a/Inversion.Naiad/ServiceContainer.cs b/Inversion.Naiad/ServiceContainer.cs index 28da6fb..7f3d12f 100644 --- a/Inversion.Naiad/ServiceContainer.cs +++ b/Inversion.Naiad/ServiceContainer.cs @@ -80,6 +80,8 @@ public T GetService(string name) where T : class { } return obj; } + } catch(Exception ex) { + throw new Exception(String.Format("Problem during GetService(\"{0}\")", name), ex); } finally { _lock.ExitReadLock(); } From 4a72fed28a349f95c2f2902b77ec2b2dbd098637 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Sat, 13 Oct 2018 23:47:50 +0100 Subject: [PATCH 14/29] adding response headers support to Inversion.Web.AspNetCore. --- .../AspNetCoreWebResponse.cs | 14 +++++++++++- .../AspNetCoreWebResponseHeaderCollection.cs | 22 +++++++++++++++++++ .../Inversion.Web.AspNetCore.csproj | 3 ++- inversion-dev.sln | 16 +++++++++++++- 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 Inversion.Web.AspNetCore/AspNetCoreWebResponseHeaderCollection.cs diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs b/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs index a9ac7bd..68f774d 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs @@ -41,7 +41,19 @@ public string StatusDescription { public IResponseCookieCollection Cookies => throw new NotImplementedException(); - public IResponseHeaderCollection Headers => throw new NotImplementedException(); + private IResponseHeaderCollection _headers; + + public IResponseHeaderCollection Headers + { + get + { + if (_headers == null) + { + _headers = new AspNetCoreWebResponseHeaderCollection(context.Response); + } + return _headers; + } + } /// /// Flushes the response steam and ends the response. diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebResponseHeaderCollection.cs b/Inversion.Web.AspNetCore/AspNetCoreWebResponseHeaderCollection.cs new file mode 100644 index 0000000..d948f82 --- /dev/null +++ b/Inversion.Web.AspNetCore/AspNetCoreWebResponseHeaderCollection.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.AspNetCore.Http; + +namespace Inversion.Web.AspNetCore +{ + public class AspNetCoreWebResponseHeaderCollection : IResponseHeaderCollection + { + private readonly HttpResponse _response; + + public AspNetCoreWebResponseHeaderCollection(HttpResponse response) + { + _response = response; + } + + public void Append(string key, string value) + { + _response.Headers.Append(key, value); + } + } +} diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj index 7c54b3e..b0e6385 100644 --- a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -3,8 +3,9 @@ netcoreapp2.0 Inversion.Web.AspNetCore - 1.0.5 + 1.0.6 Adam Christie + true diff --git a/inversion-dev.sln b/inversion-dev.sln index 01ab7c4..a5caf26 100644 --- a/inversion-dev.sln +++ b/inversion-dev.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27130.2003 +VisualStudioVersion = 15.0.27130.2026 MinimumVisualStudioVersion = 15.0.26124.0 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Inversion.Demo.Katana", "Inversion.Demo.Katana\Inversion.Demo.Katana.csproj", "{02A7C04D-3A85-4839-BD60-13AB63367A04}" EndProject @@ -12,6 +12,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Inversion.Web", "Inversion. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Inversion.Naiad", "Inversion.Naiad\Inversion.Naiad.csproj", "{7F0FAE53-557D-4567-8289-CD1B17BDC4D8}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Inversion.Web.AspNetCore", "Inversion.Web.AspNetCore\Inversion.Web.AspNetCore.csproj", "{8D674E2B-7172-43C5-8940-B6610B39F08A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -82,6 +84,18 @@ Global {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Release|x64.Build.0 = Release|Any CPU {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Release|x86.ActiveCfg = Release|Any CPU {7F0FAE53-557D-4567-8289-CD1B17BDC4D8}.Release|x86.Build.0 = Release|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Debug|x64.ActiveCfg = Debug|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Debug|x64.Build.0 = Debug|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Debug|x86.ActiveCfg = Debug|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Debug|x86.Build.0 = Debug|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Release|Any CPU.Build.0 = Release|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Release|x64.ActiveCfg = Release|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Release|x64.Build.0 = Release|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Release|x86.ActiveCfg = Release|Any CPU + {8D674E2B-7172-43C5-8940-B6610B39F08A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From e07f69bea1ea87917c5ddcfcd9206c4b86bbd0fd Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Sun, 17 Feb 2019 22:36:12 +0000 Subject: [PATCH 15/29] proper handling of request body so can read it safely and cache the result. --- .../AspNetCoreWebRequest.cs | 35 ++++++++++++++++++- .../Inversion.Web.AspNetCore.csproj | 2 +- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs index 35d2218..428a074 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Security.Principal; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Internal; using Inversion.Data; using Inversion.Web; @@ -33,7 +35,38 @@ public AspNetCoreWebRequest(HttpContext context) public IDictionary Params => new Dictionary(this.context.Request.Query.Select(q => new KeyValuePair(q.Key, string.Join(",", q.Value)))); - public string Payload => this.context.Request.Body.AsText(); + private string _cachedPayload { get; set; } + + private readonly object _payloadCacheLock = new object(); + + public string Payload + { + get + { + if (String.IsNullOrEmpty(_cachedPayload)) + { + lock (_payloadCacheLock) + { + if (String.IsNullOrEmpty(_cachedPayload)) + { + this.context.Request.EnableRewind(); + using (StreamReader reader = new StreamReader( + stream: this.context.Request.Body, + encoding: System.Text.Encoding.UTF8, + detectEncodingFromByteOrderMarks: true, + bufferSize: 1024, + leaveOpen: true)) + { + _cachedPayload = reader.ReadToEnd(); + this.context.Request.Body.Position = 0; + } + } + } + } + + return _cachedPayload; + } + } public IEnumerable Flags => this.context.Request.Query.Where(x => string.IsNullOrEmpty(x.Value)).Select(x => x.Key); diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj index b0e6385..be0b349 100644 --- a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -3,7 +3,7 @@ netcoreapp2.0 Inversion.Web.AspNetCore - 1.0.6 + 1.0.8 Adam Christie true From e4bb62ebeb3932e0e0bc0491b3ec510beafe4eee Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Thu, 14 Mar 2019 18:37:49 +0000 Subject: [PATCH 16/29] add support for pre and post action hooks in ProcessContext. --- .../Behaviour/ProcessBehaviour.cs | 4 +-- .../Behaviour/PrototypedBehaviour.cs | 4 +-- Inversion.Process/Inversion.Process.csproj | 2 +- Inversion.Process/ProcessContext.cs | 28 ++++++++++++++----- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Inversion.Process/Behaviour/ProcessBehaviour.cs b/Inversion.Process/Behaviour/ProcessBehaviour.cs index f9413dc..5a5f7e7 100644 --- a/Inversion.Process/Behaviour/ProcessBehaviour.cs +++ b/Inversion.Process/Behaviour/ProcessBehaviour.cs @@ -18,7 +18,7 @@ public string RespondsTo { return _respondsTo; } } - + /// /// Creates a new instance of the behaviour. /// @@ -97,7 +97,7 @@ public virtual void Postprocess(IEvent ev) { public virtual void Action(IEvent ev) { this.Action(ev, ev.Context); } - + /// /// The action to perform when the `Condition(IEvent)` is met. /// diff --git a/Inversion.Process/Behaviour/PrototypedBehaviour.cs b/Inversion.Process/Behaviour/PrototypedBehaviour.cs index a3da77a..6da8a1f 100644 --- a/Inversion.Process/Behaviour/PrototypedBehaviour.cs +++ b/Inversion.Process/Behaviour/PrototypedBehaviour.cs @@ -17,7 +17,7 @@ public IPrototype Prototype { get { return _prototype; } } /// - /// Provices access to component configuration stuiable for querying. + /// Provides access to component configuration suitable for querying. /// public IConfiguration Configuration { get { return _prototype; } @@ -44,7 +44,7 @@ protected PrototypedBehaviour(string respondsTo, IPrototype prototype): base(res protected PrototypedBehaviour(string respondsTo, IEnumerable config): base(respondsTo) { _prototype = new Prototype(config); } - + /// /// Determines if each of the behaviours selection criteria match. /// diff --git a/Inversion.Process/Inversion.Process.csproj b/Inversion.Process/Inversion.Process.csproj index fbe170f..a2390df 100644 --- a/Inversion.Process/Inversion.Process.csproj +++ b/Inversion.Process/Inversion.Process.csproj @@ -2,7 +2,7 @@ netstandard2.0 Inversion.Process - 1.0.5 + 1.0.6 Guy Murphy diff --git a/Inversion.Process/ProcessContext.cs b/Inversion.Process/ProcessContext.cs index 07c7500..0514a19 100644 --- a/Inversion.Process/ProcessContext.cs +++ b/Inversion.Process/ProcessContext.cs @@ -12,6 +12,18 @@ namespace Inversion.Process { + public class ActionEventArgs : EventArgs + { + private readonly IEvent _ev; + + public ActionEventArgs(IEvent ev) + { + _ev = ev; + } + + public IEvent Event => _ev; + } + /// /// Provides a processing context as a self-contained and sufficient /// channel of application execution. The context manages a set of @@ -39,6 +51,8 @@ public class ProcessContext : IProcessContext { private readonly IServiceContainer _serviceContainer; private readonly IResourceAdapter _resources; + public static event EventHandler PreAction; + public static event EventHandler PostAction; /// /// Exposes the processes service container. @@ -152,9 +166,7 @@ public IDataDictionary Params { public ProcessContext(IServiceContainer services, IResourceAdapter resources) { _serviceContainer = services; _resources = resources; - _cache = new MemoryCache(new MemoryCacheOptions { - - }); + _cache = new MemoryCache(new MemoryCacheOptions {}); _bus = new Subject(); _messages = new DataCollection(); _errors = new DataCollection(); @@ -184,7 +196,7 @@ public void Dispose() { } /// - /// Disposal that allows for partitioning of + /// Disposal that allows for partitioning of /// clean-up of managed and unmanaged resources. /// /// @@ -218,8 +230,10 @@ public virtual void Register(IProcessBehaviour behaviour) { this.Bus.Where(behaviour.Condition).Subscribe( (IEvent ev) => { try { - behaviour.Action(ev); - } catch (Exception err) { + PreAction?.Invoke(this, new ActionEventArgs(ev: ev)); + behaviour.Action(ev); + PostAction?.Invoke(this, new ActionEventArgs(ev: ev)); + } catch (Exception err) { behaviour.Rescue(ev, err); } } @@ -238,7 +252,7 @@ public virtual void Register(IEnumerable behaviours) { } /// - /// Creates and registers a runtime behaviour with this context constructed + /// Creates and registers a runtime behaviour with this context constructed /// from a predicate representing the behaviours condition, and an action /// representing the behaviours action. This behaviour will be consulted for /// any event fired on this context. From 5fec9b482c4ea594fe1d418445ca03435b272886 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Fri, 15 Mar 2019 00:06:13 +0000 Subject: [PATCH 17/29] pass behaviour instead of context to event. --- Inversion.Process/Inversion.Process.csproj | 2 +- Inversion.Process/ProcessContext.cs | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Inversion.Process/Inversion.Process.csproj b/Inversion.Process/Inversion.Process.csproj index a2390df..cdac283 100644 --- a/Inversion.Process/Inversion.Process.csproj +++ b/Inversion.Process/Inversion.Process.csproj @@ -2,7 +2,7 @@ netstandard2.0 Inversion.Process - 1.0.6 + 1.0.7 Guy Murphy diff --git a/Inversion.Process/ProcessContext.cs b/Inversion.Process/ProcessContext.cs index 0514a19..dddf6d4 100644 --- a/Inversion.Process/ProcessContext.cs +++ b/Inversion.Process/ProcessContext.cs @@ -14,13 +14,17 @@ namespace Inversion.Process { public class ActionEventArgs : EventArgs { + private readonly IProcessContext _context; private readonly IEvent _ev; - public ActionEventArgs(IEvent ev) + public ActionEventArgs(IProcessContext context, IEvent ev) { + _context = context; _ev = ev; } + public IProcessContext Context => _context; + public IEvent Event => _ev; } @@ -51,8 +55,8 @@ public class ProcessContext : IProcessContext { private readonly IServiceContainer _serviceContainer; private readonly IResourceAdapter _resources; - public static event EventHandler PreAction; - public static event EventHandler PostAction; + public static event EventHandler PreAction; + public static event EventHandler PostAction; /// /// Exposes the processes service container. @@ -230,9 +234,9 @@ public virtual void Register(IProcessBehaviour behaviour) { this.Bus.Where(behaviour.Condition).Subscribe( (IEvent ev) => { try { - PreAction?.Invoke(this, new ActionEventArgs(ev: ev)); + PreAction?.Invoke(behaviour, new ActionEventArgs(context: this, ev: ev)); behaviour.Action(ev); - PostAction?.Invoke(this, new ActionEventArgs(ev: ev)); + PostAction?.Invoke(behaviour, new ActionEventArgs(context: this, ev: ev)); } catch (Exception err) { behaviour.Rescue(ev, err); } From 0d4a55412064764b648076e015efb9da35348cbf Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Fri, 15 Mar 2019 01:24:57 +0000 Subject: [PATCH 18/29] move event to delegate so other classes have access. --- Inversion.Process/Inversion.Process.csproj | 2 +- Inversion.Process/ProcessContext.cs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Inversion.Process/Inversion.Process.csproj b/Inversion.Process/Inversion.Process.csproj index cdac283..6a0d23e 100644 --- a/Inversion.Process/Inversion.Process.csproj +++ b/Inversion.Process/Inversion.Process.csproj @@ -2,7 +2,7 @@ netstandard2.0 Inversion.Process - 1.0.7 + 1.0.9 Guy Murphy diff --git a/Inversion.Process/ProcessContext.cs b/Inversion.Process/ProcessContext.cs index dddf6d4..0773b2c 100644 --- a/Inversion.Process/ProcessContext.cs +++ b/Inversion.Process/ProcessContext.cs @@ -55,8 +55,9 @@ public class ProcessContext : IProcessContext { private readonly IServiceContainer _serviceContainer; private readonly IResourceAdapter _resources; - public static event EventHandler PreAction; - public static event EventHandler PostAction; + public delegate void ActionEventHandler(object sender, ActionEventArgs args); + public static ActionEventHandler PreAction; + public static ActionEventHandler PostAction; /// /// Exposes the processes service container. @@ -236,7 +237,7 @@ public virtual void Register(IProcessBehaviour behaviour) { try { PreAction?.Invoke(behaviour, new ActionEventArgs(context: this, ev: ev)); behaviour.Action(ev); - PostAction?.Invoke(behaviour, new ActionEventArgs(context: this, ev: ev)); + PostAction?.Invoke(behaviour, new ActionEventArgs(context: this, ev: ev)); } catch (Exception err) { behaviour.Rescue(ev, err); } From 63bba89011a1dfbe929503169bdc64e3e0c5b52e Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Fri, 29 Mar 2019 11:43:07 +0000 Subject: [PATCH 19/29] adding Configuration.Empty as a declarative way of giving an empty Configuration set. --- Inversion.Process/Configuration.cs | 11 ++++++----- Inversion.Process/Inversion.Process.csproj | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Inversion.Process/Configuration.cs b/Inversion.Process/Configuration.cs index b8234e1..feb1f7f 100644 --- a/Inversion.Process/Configuration.cs +++ b/Inversion.Process/Configuration.cs @@ -9,7 +9,9 @@ namespace Inversion.Process { /// Provides an immutable, ordered collection of /// configuration elements. /// - public class Configuration : IConfiguration { + public class Configuration : IConfiguration + { + public static Builder Empty = new Builder {}; private readonly ImmutableHashSet _elements; @@ -40,7 +42,7 @@ public Configuration(IEnumerable elements) { /// /// The frame to get the elements for. /// Returns an enumerable of the matching elements. - public IEnumerable GetElements(string frame) { + public IEnumerable GetElements(string frame) { return this.Elements.Where(element => element.Frame == frame).OrderBy(e => e.Ordinal); } @@ -75,7 +77,7 @@ public IEnumerable GetElements(string frame, string slot, public string GetValue(string frame, string slot, string name) { return this.GetValues(frame, slot, name).FirstOrDefault(); } - + /// /// Gets the specified values from the configuration. /// @@ -269,7 +271,7 @@ public Element(int ordinal, string frame, string slot, string name, string value /// rather than say from Spring config the likes of... /// /// - /// new ParameterisedSequenceBehaviour("process-request", + /// new ParameterisedSequenceBehaviour("process-request", /// new Configuration.Builder { /// {"fire", "bootstrap"}, /// {"fire", "parse-request"}, @@ -286,7 +288,6 @@ public Element(int ordinal, string frame, string slot, string name, string value /// /// public class Builder : HashSet { - /// /// Produces a configuration from the builder. /// diff --git a/Inversion.Process/Inversion.Process.csproj b/Inversion.Process/Inversion.Process.csproj index 6a0d23e..04441a9 100644 --- a/Inversion.Process/Inversion.Process.csproj +++ b/Inversion.Process/Inversion.Process.csproj @@ -2,7 +2,7 @@ netstandard2.0 Inversion.Process - 1.0.9 + 1.0.10 Guy Murphy From bd388621cb6db5ca315d02520bbb103815ee53e7 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Tue, 9 Apr 2019 13:06:01 +0100 Subject: [PATCH 20/29] adding AspNetCoreCookie abstraction for request and response. --- Inversion.Web.AspNetCore/AspNetCoreCookie.cs | 41 ++++++++ .../AspNetCoreWebCookieCollection.cs | 95 +++++++++++++++++++ .../AspNetCoreWebRequest.cs | 2 +- .../AspNetCoreWebResponse.cs | 4 +- .../Inversion.Web.AspNetCore.csproj | 2 +- 5 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 Inversion.Web.AspNetCore/AspNetCoreCookie.cs create mode 100644 Inversion.Web.AspNetCore/AspNetCoreWebCookieCollection.cs diff --git a/Inversion.Web.AspNetCore/AspNetCoreCookie.cs b/Inversion.Web.AspNetCore/AspNetCoreCookie.cs new file mode 100644 index 0000000..0570eb3 --- /dev/null +++ b/Inversion.Web.AspNetCore/AspNetCoreCookie.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Inversion.Web.AspNetCore +{ + public class AspNetCoreCookie + { + private string[] _values = new String[] { }; + public CookieOptions Options; + + public AspNetCoreCookie(string value, CookieOptions options = null) + { + _values = new string[] { value }; + this.Options = options; + } + + public AspNetCoreCookie(string[] values, CookieOptions options = null) + { + _values = values; + this.Options = options; + } + + public string GetValue() + { + return String.Join('&', _values); + } + + public string[] GetValues() + { + return _values; + } + + public IDictionary AsDictionary() + { + return _values.ToDictionary( + x => x.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[0], + x => x.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1]); + } + } +} \ No newline at end of file diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebCookieCollection.cs b/Inversion.Web.AspNetCore/AspNetCoreWebCookieCollection.cs new file mode 100644 index 0000000..6461467 --- /dev/null +++ b/Inversion.Web.AspNetCore/AspNetCoreWebCookieCollection.cs @@ -0,0 +1,95 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace Inversion.Web.AspNetCore +{ + public class AspNetCoreWebCookieCollection : IRequestCookieCollection, IResponseCookieCollection + { + private readonly Dictionary _collection = new Dictionary(); + public AspNetCoreWebCookieCollection() { } + + public AspNetCoreWebCookieCollection(IEnumerable> source) + { + foreach (KeyValuePair kvp in source) + { + this.Append(kvp.Key, kvp.Value); + } + } + + public string Get(string key) + { + return _collection[key].GetValue(); + } + + public bool TryGetValue(string key, out string value) + { + AspNetCoreCookie cookie = null; + if (_collection.TryGetValue(key, out cookie)) + { + value = cookie.GetValue(); + return true; + } + value = null; + return false; + } + + public IDictionary GetValues(string key) + { + return _collection[key].AsDictionary(); + } + + public bool TryGetValues(string key, out IDictionary values) + { + if (_collection.ContainsKey(key)) + { + values = this.GetValues(key); + return true; + } + + values = null; + return false; + } + + public string this[string key] => this.Get(key); + + public void Append(string key, string value, CookieOptions options) + { + // ignore options for now + _collection.Add(key, new AspNetCoreCookie(value)); + } + + public void Append(string key, string value) + { + _collection.Add(key, new AspNetCoreCookie(value)); + } + + public void Delete(string key) + { + _collection.Remove(key); + } + + public void Append(string key, string[] values, CookieOptions options) + { + _collection.Add(key, new AspNetCoreCookie(values, options)); + } + + public void Append(string key, string[] values) + { + _collection.Add(key, new AspNetCoreCookie(values)); + } + + public IEnumerator> GetEnumerator() + { + foreach(string key in _collection.Keys) + { + yield return new KeyValuePair(key, this[key]); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs index 428a074..bde08ac 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs @@ -72,6 +72,6 @@ public string Payload public IDictionary Headers => this.context.Request.Headers.ToDictionary(x => x.Key, x => string.Join(",", x.Value)); - public Web.IRequestCookieCollection Cookies => throw new NotImplementedException(); + public Web.IRequestCookieCollection Cookies => new AspNetCoreWebCookieCollection(this.context.Request.Cookies); } } \ No newline at end of file diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs b/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs index 68f774d..45d1bb3 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs @@ -39,7 +39,9 @@ public string StatusDescription { public string ContentType { get => this.context.Response.ContentType; set => this.context.Response.ContentType = value; } - public IResponseCookieCollection Cookies => throw new NotImplementedException(); + private readonly AspNetCoreWebCookieCollection _cookies = new AspNetCoreWebCookieCollection(); + + public IResponseCookieCollection Cookies => _cookies; private IResponseHeaderCollection _headers; diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj index be0b349..59ce246 100644 --- a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -3,7 +3,7 @@ netcoreapp2.0 Inversion.Web.AspNetCore - 1.0.8 + 1.0.9 Adam Christie true From def1b24be8cd3af0be8279fd2a9302d37a5aa3c6 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Tue, 21 May 2019 17:26:28 +0100 Subject: [PATCH 21/29] new aspnetcore response cookie model. --- .../AspNetCoreWebRequest.cs | 2 +- ...> AspNetCoreWebRequestCookieCollection.cs} | 49 +++++++++--------- .../AspNetCoreWebResponse.cs | 21 +++++--- .../AspNetCoreWebResponseCookieCollection.cs | 51 +++++++++++++++++++ .../Inversion.Web.AspNetCore.csproj | 2 +- 5 files changed, 90 insertions(+), 35 deletions(-) rename Inversion.Web.AspNetCore/{AspNetCoreWebCookieCollection.cs => AspNetCoreWebRequestCookieCollection.cs} (61%) create mode 100644 Inversion.Web.AspNetCore/AspNetCoreWebResponseCookieCollection.cs diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs index bde08ac..3a0b122 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs @@ -72,6 +72,6 @@ public string Payload public IDictionary Headers => this.context.Request.Headers.ToDictionary(x => x.Key, x => string.Join(",", x.Value)); - public Web.IRequestCookieCollection Cookies => new AspNetCoreWebCookieCollection(this.context.Request.Cookies); + public Web.IRequestCookieCollection Cookies => new AspNetCoreWebRequestCookieCollection(this.context.Request.Cookies); } } \ No newline at end of file diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebCookieCollection.cs b/Inversion.Web.AspNetCore/AspNetCoreWebRequestCookieCollection.cs similarity index 61% rename from Inversion.Web.AspNetCore/AspNetCoreWebCookieCollection.cs rename to Inversion.Web.AspNetCore/AspNetCoreWebRequestCookieCollection.cs index 6461467..a6935c5 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebCookieCollection.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebRequestCookieCollection.cs @@ -4,16 +4,15 @@ namespace Inversion.Web.AspNetCore { - public class AspNetCoreWebCookieCollection : IRequestCookieCollection, IResponseCookieCollection + public class AspNetCoreWebRequestCookieCollection : IRequestCookieCollection { private readonly Dictionary _collection = new Dictionary(); - public AspNetCoreWebCookieCollection() { } - public AspNetCoreWebCookieCollection(IEnumerable> source) + public AspNetCoreWebRequestCookieCollection(IEnumerable> source) { foreach (KeyValuePair kvp in source) { - this.Append(kvp.Key, kvp.Value); + _collection.Add(kvp.Key, new AspNetCoreCookie(kvp.Value)); } } @@ -53,31 +52,31 @@ public bool TryGetValues(string key, out IDictionary values) public string this[string key] => this.Get(key); - public void Append(string key, string value, CookieOptions options) - { - // ignore options for now - _collection.Add(key, new AspNetCoreCookie(value)); - } + //public void Append(string key, string value, CookieOptions options) + //{ + // // ignore options for now + // _collection.Add(key, new AspNetCoreCookie(value)); + //} - public void Append(string key, string value) - { - _collection.Add(key, new AspNetCoreCookie(value)); - } + //public void Append(string key, string value) + //{ + // _collection.Add(key, new AspNetCoreCookie(value)); + //} - public void Delete(string key) - { - _collection.Remove(key); - } + //public void Delete(string key) + //{ + // _collection.Remove(key); + //} - public void Append(string key, string[] values, CookieOptions options) - { - _collection.Add(key, new AspNetCoreCookie(values, options)); - } + //public void Append(string key, string[] values, CookieOptions options) + //{ + // _collection.Add(key, new AspNetCoreCookie(values, options)); + //} - public void Append(string key, string[] values) - { - _collection.Add(key, new AspNetCoreCookie(values)); - } + //public void Append(string key, string[] values) + //{ + // _collection.Add(key, new AspNetCoreCookie(values)); + //} public IEnumerator> GetEnumerator() { diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs b/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs index 45d1bb3..d2c7020 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebResponse.cs @@ -1,15 +1,9 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Security.Principal; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http; -using Inversion.Process; -using Inversion.Web; - namespace Inversion.Web.AspNetCore { public class AspNetCoreWebResponse : IWebResponse @@ -39,9 +33,20 @@ public string StatusDescription { public string ContentType { get => this.context.Response.ContentType; set => this.context.Response.ContentType = value; } - private readonly AspNetCoreWebCookieCollection _cookies = new AspNetCoreWebCookieCollection(); + private AspNetCoreWebResponseCookieCollection _cookies; - public IResponseCookieCollection Cookies => _cookies; + public IResponseCookieCollection Cookies + { + get + { + if (_cookies == null) + { + _cookies = new AspNetCoreWebResponseCookieCollection(context.Response.Cookies); + } + + return _cookies; + } + } private IResponseHeaderCollection _headers; diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebResponseCookieCollection.cs b/Inversion.Web.AspNetCore/AspNetCoreWebResponseCookieCollection.cs new file mode 100644 index 0000000..80ce510 --- /dev/null +++ b/Inversion.Web.AspNetCore/AspNetCoreWebResponseCookieCollection.cs @@ -0,0 +1,51 @@ +using System; + +namespace Inversion.Web.AspNetCore +{ + public class AspNetCoreWebResponseCookieCollection : IResponseCookieCollection + { + private readonly Microsoft.AspNetCore.Http.IResponseCookies _cookies; + + public AspNetCoreWebResponseCookieCollection(Microsoft.AspNetCore.Http.IResponseCookies cookies) + { + _cookies = cookies; + } + + public void Append(string key, string value, CookieOptions options) + { + Microsoft.AspNetCore.Http.CookieOptions cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); + if (!String.IsNullOrEmpty(options.Domain)) cookieOptions.Domain = options.Domain; + if (options.Secure) cookieOptions.Secure = true; + if (options.HttpOnly) cookieOptions.HttpOnly = true; + if (options.Expires != null) cookieOptions.Expires = options.Expires.Value; + + _cookies.Append(key, value, cookieOptions); + } + + public void Append(string key, string value) + { + _cookies.Append(key, value); + } + + public void Delete(string key) + { + _cookies.Delete(key); + } + + public void Append(string key, string[] values, CookieOptions options) + { + Microsoft.AspNetCore.Http.CookieOptions cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); + if (!String.IsNullOrEmpty(options.Domain)) cookieOptions.Domain = options.Domain; + if (options.Secure) cookieOptions.Secure = true; + if (options.HttpOnly) cookieOptions.HttpOnly = true; + if (options.Expires != null) cookieOptions.Expires = options.Expires.Value; + + _cookies.Append(key, String.Join(',', values), cookieOptions); + } + + public void Append(string key, string[] values) + { + _cookies.Append(key, String.Join(',', values)); + } + } +} diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj index 59ce246..459479e 100644 --- a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -3,7 +3,7 @@ netcoreapp2.0 Inversion.Web.AspNetCore - 1.0.9 + 1.0.10 Adam Christie true From 7e5b97c20f3176d5ef4c076bd8cdf4fda0c1d3e9 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Thu, 30 May 2019 13:39:58 +0100 Subject: [PATCH 22/29] adding diagnostics option to XsltViewBehaviour to investigate problems on .net core. --- .../Behaviour/View/XsltViewBehaviour.cs | 116 ++++++++++++------ Inversion.Web/Inversion.Web.csproj | 1 + 2 files changed, 77 insertions(+), 40 deletions(-) diff --git a/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs b/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs index b8efad2..7ae2319 100644 --- a/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs +++ b/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Reflection; using System.Text; using System.Xml; using System.Xml.Xsl; @@ -8,13 +9,14 @@ using Inversion.Data; using Inversion.Process; using Inversion.Process.Behaviour; +using log4net; namespace Inversion.Web.Behaviour.View { /// /// A behaviour that will transform the last view step by attempting to find /// an appropriate XSL style sheet, based upon the context params - /// of *area*, *concern*, and *action*. + /// of *area*, *concern*, and *action*. /// /// /// This is intended for use in Web application, not as a general @@ -23,12 +25,14 @@ namespace Inversion.Web.Behaviour.View { public class XsltViewBehaviour : ProcessBehaviour { - // This is a piece of voodoo I was handed by a friend who had some - // similar occasional encoding problems which apparently are - // due to an underlying problem in the BCL. - // Find out if its still relevant and what exactly its doing. + private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private class StringWriterWithEncoding : StringWriter { + // This is a piece of voodoo I was handed by a friend who had some + // similar occasional encoding problems which apparently are + // due to an underlying problem in the BCL. + // Find out if its still relevant and what exactly its doing. + + private class StringWriterWithEncoding : StringWriter { private readonly Encoding _encoding; public StringWriterWithEncoding(StringBuilder builder, Encoding encoding) @@ -46,6 +50,7 @@ public override Encoding Encoding { private readonly string _contentType; private readonly bool _enableCache; private readonly bool _disableDirective; + private readonly bool _diagnostics; /// /// Instantiates a new xslt view behaviour used to provide xslt templating @@ -57,19 +62,34 @@ public override Encoding Encoding { /// public XsltViewBehaviour(string respondsTo) : this(respondsTo, "text/xml") { } - /// - /// Instantiates a new xslt view behaviour used to provide xslt templating - /// primarily for web applications. - /// - /// The message the behaviour has set as responding to. - /// The content type of the view step produced from this behaviour. - /// - /// Defaults to caching compiled xslt. - /// - public XsltViewBehaviour(string respondsTo, string contentType) + /// + /// Instantiates a new xslt view behaviour used to provide xslt templating + /// primarily for web applications. + /// + /// The message the behaviour has set as responding to. + /// Specifies whether or not the xslt compilation should be cached. + /// Defaults to a content type of "text/xml". + public XsltViewBehaviour(string respondsTo, bool enableCache) + : this(respondsTo) + { + _enableCache = enableCache; + } + + /// + /// Instantiates a new xslt view behaviour used to provide xslt templating + /// primarily for web applications. + /// + /// The message the behaviour has set as responding to. + /// The content type of the view step produced from this behaviour. + /// Add diagnostics log output + /// + /// Defaults to caching compiled xslt. + /// + public XsltViewBehaviour(string respondsTo, string contentType, bool diagnostics = false) : base(respondsTo) { _contentType = contentType; _enableCache = true; + _diagnostics = diagnostics; } /// @@ -79,10 +99,11 @@ public XsltViewBehaviour(string respondsTo, string contentType) /// The message the behaviour has set as responding to. /// The content type of the view step produced from this behaviour. /// Specifies whether or not the xslt compilation should be cached. - public XsltViewBehaviour(string respondsTo, string contentType, bool enableCache) + public XsltViewBehaviour(string respondsTo, string contentType, bool enableCache, bool diagnostics = false) : this(respondsTo, contentType) { _enableCache = enableCache; - } + _diagnostics = diagnostics; + } /// /// Instantiates a new xslt view behaviour used to provide xslt templating @@ -92,25 +113,14 @@ public XsltViewBehaviour(string respondsTo, string contentType, bool enableCache /// The content type of the view step produced from this behaviour. /// Specifies whether or not the xslt compilation should be cached. /// Specifies whether or not to disable the xml directive. - public XsltViewBehaviour(string respondsTo, string contentType, bool enableCache, bool disableDirective) + public XsltViewBehaviour(string respondsTo, string contentType, bool enableCache, bool disableDirective, bool diagnostics = false) : this(respondsTo, contentType) { _enableCache = enableCache; _disableDirective = disableDirective; + _diagnostics = diagnostics; } - /// - /// Instantiates a new xslt view behaviour used to provide xslt templating - /// primarily for web applications. - /// - /// The message the behaviour has set as responding to. - /// Specifies whether or not the xslt compilation should be cached. - /// Defaults to a content type of "text/xml". - public XsltViewBehaviour(string respondsTo, bool enableCache) - : this(respondsTo) { - _enableCache = enableCache; - } - // The iterator generated for this should be // ThreadLocal and therefore safe to use // in this manner on a singleton, would be @@ -142,7 +152,7 @@ private IEnumerable _possibleTemplates(IProcessContext context) { /// /// Takes the content of the last view-step and transforms it with the xslt with the location - /// that best matches the path of the url. + /// that best matches the path of the url. /// /// The event that gave rise to this action. /// The context within which this action is being performed. @@ -163,10 +173,20 @@ public override void Action(IEvent ev, IProcessContext context) { if (xsl == null) { // we dont have it cached - // does the file exist? + // does the file exist? string templatePath = Path.Combine("Resources", "Views", "Xslt", templateName); + + if (_diagnostics) + { + _log.DebugFormat("Checking path {0}", templatePath); + } + if (context.Resources.Exists(templatePath)){ - xsl = context.Resources.Open(templatePath).AsXslDocument(); + if (_diagnostics) + { + _log.DebugFormat("Path {0} exists", templatePath); + } + xsl = context.Resources.Open(templatePath).AsXslDocument(); if (_enableCache) { var cacheEntry = context.ObjectCache.CreateEntry(cacheKey); cacheEntry.Value = xsl; @@ -175,16 +195,20 @@ public override void Action(IEvent ev, IProcessContext context) { } // do the actual transform if (xsl != null) { - // copy forward the parameters from the context - // to the xsl stylesheet, with no namespace - XsltArgumentList args = new XsltArgumentList(); + if (_diagnostics) + { + _log.DebugFormat("XSL loaded"); + } + // copy forward the parameters from the context + // to the xsl stylesheet, with no namespace + XsltArgumentList args = new XsltArgumentList(); foreach (KeyValuePair parm in context.Params) { args.AddParam(parm.Key, "", parm.Value); } StringBuilder result = new StringBuilder(); XmlDocument input = new XmlDocument(); - + string inputText = context.ViewSteps.Last.Content ?? context.ViewSteps.Last.Model.ToXml(); input.LoadXml(inputText); @@ -199,18 +223,30 @@ public override void Action(IEvent ev, IProcessContext context) { using (XmlWriter writer = XmlWriter.Create(result, writerSettings)) { xsl.Transform(input, args, writer); - } + if (_diagnostics) + { + _log.DebugFormat("Transformed"); + } + } } else { using (StringWriterWithEncoding writer = new StringWriterWithEncoding(result, Encoding.UTF8)) { xsl.Transform(input, args, writer); + if (_diagnostics) + { + _log.DebugFormat("Transformed"); + } } } context.ViewSteps.CreateStep(templateName, _contentType, result.ToString()); - break; // we've found and processed our template, no need to keep looking + if (_diagnostics) + { + _log.DebugFormat("ViewStep created"); + } + break; // we've found and processed our template, no need to keep looking } } diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index 362ec4b..bb5a675 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -9,6 +9,7 @@ + From 776eb7368323f9895bea4ee32fde69a1da37a910 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Thu, 30 May 2019 14:54:06 +0100 Subject: [PATCH 23/29] 1.0.8 - workaround for XslCompiledTransform bug https://github.com/dotnet/corefx/issues/23343 --- .../Behaviour/View/XsltViewBehaviour.cs | 70 +++++++++++-------- Inversion.Web/Inversion.Web.csproj | 2 +- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs b/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs index 7ae2319..335e950 100644 --- a/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs +++ b/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs @@ -186,6 +186,9 @@ public override void Action(IEvent ev, IProcessContext context) { { _log.DebugFormat("Path {0} exists", templatePath); } + + xsl = new XslCompiledTransform(enableDebug: false); + xsl.Load(templatePath); xsl = context.Resources.Open(templatePath).AsXslDocument(); if (_enableCache) { var cacheEntry = context.ObjectCache.CreateEntry(cacheKey); @@ -206,47 +209,56 @@ public override void Action(IEvent ev, IProcessContext context) { args.AddParam(parm.Key, "", parm.Value); } - StringBuilder result = new StringBuilder(); - XmlDocument input = new XmlDocument(); + try + { + StringBuilder result = new StringBuilder(); + XmlDocument input = new XmlDocument(); - string inputText = context.ViewSteps.Last.Content ?? context.ViewSteps.Last.Model.ToXml(); - input.LoadXml(inputText); + string inputText = context.ViewSteps.Last.Content ?? context.ViewSteps.Last.Model.ToXml(); + input.LoadXml(inputText); - if (_disableDirective) - { - XmlWriterSettings writerSettings = new XmlWriterSettings + if (_disableDirective) { - OmitXmlDeclaration = true, - ConformanceLevel = ConformanceLevel.Auto - }; - using (XmlWriter writer = XmlWriter.Create(result, writerSettings)) - { - xsl.Transform(input, args, writer); - if (_diagnostics) + XmlWriterSettings writerSettings = new XmlWriterSettings + { + OmitXmlDeclaration = true, + ConformanceLevel = ConformanceLevel.Auto + }; + using (XmlWriter writer = XmlWriter.Create(result, writerSettings)) { - _log.DebugFormat("Transformed"); + xsl.Transform(input, args, writer); + if (_diagnostics) + { + _log.DebugFormat("Transformed"); + } } - } - } - else - { - using (StringWriterWithEncoding writer = new StringWriterWithEncoding(result, Encoding.UTF8)) + } + else { - xsl.Transform(input, args, writer); - if (_diagnostics) + using (StringWriterWithEncoding writer = new StringWriterWithEncoding(result, Encoding.UTF8)) { - _log.DebugFormat("Transformed"); + xsl.Transform(input, args, writer); + if (_diagnostics) + { + _log.DebugFormat("Transformed"); + } } - } - } + } - context.ViewSteps.CreateStep(templateName, _contentType, result.ToString()); - if (_diagnostics) + context.ViewSteps.CreateStep(templateName, _contentType, result.ToString()); + if (_diagnostics) + { + _log.DebugFormat("ViewStep created"); + } + + break; // we've found and processed our template, no need to keep looking + } + catch (Exception ex) { - _log.DebugFormat("ViewStep created"); + _log.ErrorFormat("Problem during Transform: {0}", ex.ToString()); + throw; } - break; // we've found and processed our template, no need to keep looking } } diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index bb5a675..cdac948 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -3,7 +3,7 @@ netstandard2.0 Inversion.Web - 1.0.5 + 1.0.8 Guy Murphy From fd4cde94359ff27558f361b14ad256c80fd17f30 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Thu, 30 May 2019 15:11:44 +0100 Subject: [PATCH 24/29] 1.0.9 - forgot to remove old instantiation of XslCompiledTransform. --- Inversion.Web/Behaviour/View/XsltViewBehaviour.cs | 2 +- Inversion.Web/Inversion.Web.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs b/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs index 335e950..3633e76 100644 --- a/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs +++ b/Inversion.Web/Behaviour/View/XsltViewBehaviour.cs @@ -189,7 +189,7 @@ public override void Action(IEvent ev, IProcessContext context) { xsl = new XslCompiledTransform(enableDebug: false); xsl.Load(templatePath); - xsl = context.Resources.Open(templatePath).AsXslDocument(); + //xsl = context.Resources.Open(templatePath).AsXslDocument(); if (_enableCache) { var cacheEntry = context.ObjectCache.CreateEntry(cacheKey); cacheEntry.Value = xsl; diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index cdac948..33efec1 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -3,7 +3,7 @@ netstandard2.0 Inversion.Web - 1.0.8 + 1.0.9 Guy Murphy From 5dd6f874d679eba4bbb84ef9846741259820da4f Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Tue, 16 Jul 2019 12:15:22 +0100 Subject: [PATCH 25/29] improved cookie handling. --- Inversion.Web.AspNetCore/AspNetCoreCookie.cs | 29 +++++++++++++++++-- .../AspNetCoreWebRequest.cs | 22 +++++++++++++- .../Inversion.Web.AspNetCore.csproj | 2 +- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/Inversion.Web.AspNetCore/AspNetCoreCookie.cs b/Inversion.Web.AspNetCore/AspNetCoreCookie.cs index 0570eb3..2b68de6 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreCookie.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreCookie.cs @@ -6,19 +6,42 @@ namespace Inversion.Web.AspNetCore { public class AspNetCoreCookie { - private string[] _values = new String[] { }; + private readonly string[] _values; public CookieOptions Options; public AspNetCoreCookie(string value, CookieOptions options = null) { - _values = new string[] { value }; this.Options = options; + + if (value.Contains(',')) + { + _values = value.Split(',', StringSplitOptions.RemoveEmptyEntries); + } + else + { + _values = new string[] { value }; + } } public AspNetCoreCookie(string[] values, CookieOptions options = null) { - _values = values; this.Options = options; + + List candidate = new List(); + + foreach (string value in values) + { + if (value.Contains(',')) + { + candidate.AddRange(value.Split(',', StringSplitOptions.RemoveEmptyEntries)); + } + else + { + candidate.Add(value); + } + } + + _values = candidate.ToArray(); } public string GetValue() diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs index 3a0b122..b26415d 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs @@ -33,7 +33,27 @@ public AspNetCoreWebRequest(HttpContext context) public bool IsPost => this.Method.ToLower() == "post"; - public IDictionary Params => new Dictionary(this.context.Request.Query.Select(q => new KeyValuePair(q.Key, string.Join(",", q.Value)))); + public IDictionary Params + { + get + { + Dictionary requestParams = new Dictionary(); + foreach(KeyValuePair kvp in this.context.Request.Query.Select(q => new KeyValuePair(q.Key, string.Join(",", q.Value)))) + { + requestParams.Add(kvp.Key, kvp.Value); + } + + if (context.Request.HasFormContentType && context.Request.Form != null && context.Request.Form.Count > 0) + { + foreach (KeyValuePair kvp in this.context.Request.Form.Select(q => new KeyValuePair(q.Key, q.Value))) + { + requestParams.Add(kvp.Key, kvp.Value); + } + } + + return requestParams; + } + } private string _cachedPayload { get; set; } diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj index 459479e..9813592 100644 --- a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -3,7 +3,7 @@ netcoreapp2.0 Inversion.Web.AspNetCore - 1.0.10 + 1.0.13 Adam Christie true From 71d7b15f1c5569e3158fb9c1530e7d223750e6dc Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Tue, 17 Sep 2019 09:30:57 +0100 Subject: [PATCH 26/29] adding version increase. --- Inversion.Web/Inversion.Web.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index 33efec1..a3adfbf 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -3,7 +3,7 @@ netstandard2.0 Inversion.Web - 1.0.9 + 1.0.10 Guy Murphy From ce749c9fbc5e447bd8a54c1097b3f15299fda5d9 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Tue, 17 Sep 2019 09:31:39 +0100 Subject: [PATCH 27/29] fledgling Inversion.Web.AspNetCore request files implementation. --- .../AspNetCoreWebRequest.cs | 2 +- .../AspNetCoreWebRequestFile.cs | 20 +++++++ .../AspNetCoreWebRequestFiles.cs | 59 +++++++++++++++++++ .../Inversion.Web.AspNetCore.csproj | 2 +- 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 Inversion.Web.AspNetCore/AspNetCoreWebRequestFile.cs create mode 100644 Inversion.Web.AspNetCore/AspNetCoreWebRequestFiles.cs diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs index b26415d..dc959cb 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebRequest.cs @@ -22,7 +22,7 @@ public AspNetCoreWebRequest(HttpContext context) this.context = context; } - public IRequestFilesCollection Files => throw new NotImplementedException(); + public IRequestFilesCollection Files => new AspNetCoreWebRequestFiles(this.context.Request.Form.Files); // TODO: convert this less weird. The port is missing. public UrlInfo UrlInfo => new UrlInfo(new Uri($"{this.context.Request.Scheme}://{this.context.Request.Host}/{this.context.Request.Path.Value}?{this.context.Request.QueryString}")); diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebRequestFile.cs b/Inversion.Web.AspNetCore/AspNetCoreWebRequestFile.cs new file mode 100644 index 0000000..c28d90c --- /dev/null +++ b/Inversion.Web.AspNetCore/AspNetCoreWebRequestFile.cs @@ -0,0 +1,20 @@ +using System.IO; +using Microsoft.AspNetCore.Http; + +namespace Inversion.Web.AspNetCore +{ + public class AspNetCoreWebRequestFile : IRequestFile + { + private readonly IFormFile _underlyingFile; + + public AspNetCoreWebRequestFile(IFormFile underlyingFile) + { + _underlyingFile = underlyingFile; + } + + public string FileName => _underlyingFile.FileName; + public string ContentType => _underlyingFile.ContentType; + + public Stream Content => _underlyingFile.OpenReadStream(); + } +} \ No newline at end of file diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebRequestFiles.cs b/Inversion.Web.AspNetCore/AspNetCoreWebRequestFiles.cs new file mode 100644 index 0000000..f0ffcb0 --- /dev/null +++ b/Inversion.Web.AspNetCore/AspNetCoreWebRequestFiles.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using Microsoft.AspNetCore.Http; + +namespace Inversion.Web.AspNetCore +{ + public class AspNetCoreWebRequestFiles : IRequestFilesCollection + { + private readonly IFormFileCollection _files; + private IDictionary _memo; + + public AspNetCoreWebRequestFiles(IFormFileCollection underlyingCollection) + { + _files = underlyingCollection; + } + + public IEnumerator> GetEnumerator() + { + return Memo.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + protected IDictionary Memo + { + get + { + if (_memo == null) + { + _memo = new Dictionary(); + foreach (IFormFile file in _files) + { + _memo[file.FileName] = new AspNetCoreWebRequestFile(file); + } + } + return _memo; + } + } + + public IRequestFile this[string key] => this.Get(key); + + public IRequestFile Get(string key) + { + IRequestFile value; + this.TryGetValue(key, out value); + return value; + } + + public bool TryGetValue(string key, out IRequestFile value) + { + return this.Memo.TryGetValue(key, out value); + } + } +} diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj index 9813592..0fe76bf 100644 --- a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -3,7 +3,7 @@ netcoreapp2.0 Inversion.Web.AspNetCore - 1.0.13 + 1.0.15 Adam Christie true From b4d92c779ed90ba7f0e844e8eb4d2ebaf78b68ea Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Thu, 2 Jan 2020 17:11:57 +0000 Subject: [PATCH 28/29] 1.0.11 adding support for SameSite cookie option. --- Inversion.Web/CookieOptions.cs | 9 +++++++++ Inversion.Web/Inversion.Web.csproj | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Inversion.Web/CookieOptions.cs b/Inversion.Web/CookieOptions.cs index 542982f..cf5b9a3 100644 --- a/Inversion.Web/CookieOptions.cs +++ b/Inversion.Web/CookieOptions.cs @@ -25,6 +25,15 @@ public class CookieOptions { /// public bool Secure { get; set; } + public enum CookieOptionSameSite + { + None, + Lax, + Strict + } + + public CookieOptionSameSite SameSite { get; set; } + /// /// When the cookie should expire. /// diff --git a/Inversion.Web/Inversion.Web.csproj b/Inversion.Web/Inversion.Web.csproj index a3adfbf..2a4c69e 100644 --- a/Inversion.Web/Inversion.Web.csproj +++ b/Inversion.Web/Inversion.Web.csproj @@ -3,7 +3,7 @@ netstandard2.0 Inversion.Web - 1.0.10 + 1.0.11 Guy Murphy From 994894ded9b670dbd91e7f90c13e9d2bda3985b5 Mon Sep 17 00:00:00 2001 From: Adam Christie Date: Thu, 2 Jan 2020 17:24:10 +0000 Subject: [PATCH 29/29] 1.0.16 add support for SameSite cookie option. --- .../AspNetCoreWebResponseCookieCollection.cs | 14 ++++++++++++++ .../Inversion.Web.AspNetCore.csproj | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Inversion.Web.AspNetCore/AspNetCoreWebResponseCookieCollection.cs b/Inversion.Web.AspNetCore/AspNetCoreWebResponseCookieCollection.cs index 80ce510..5da2cb0 100644 --- a/Inversion.Web.AspNetCore/AspNetCoreWebResponseCookieCollection.cs +++ b/Inversion.Web.AspNetCore/AspNetCoreWebResponseCookieCollection.cs @@ -19,6 +19,13 @@ public void Append(string key, string value, CookieOptions options) if (options.HttpOnly) cookieOptions.HttpOnly = true; if (options.Expires != null) cookieOptions.Expires = options.Expires.Value; + switch (options.SameSite) + { + case CookieOptions.CookieOptionSameSite.None: cookieOptions.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.None; break; + case CookieOptions.CookieOptionSameSite.Lax: cookieOptions.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Lax; break; + case CookieOptions.CookieOptionSameSite.Strict: cookieOptions.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Strict; break; + } + _cookies.Append(key, value, cookieOptions); } @@ -40,6 +47,13 @@ public void Append(string key, string[] values, CookieOptions options) if (options.HttpOnly) cookieOptions.HttpOnly = true; if (options.Expires != null) cookieOptions.Expires = options.Expires.Value; + switch (options.SameSite) + { + case CookieOptions.CookieOptionSameSite.None: cookieOptions.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.None; break; + case CookieOptions.CookieOptionSameSite.Lax: cookieOptions.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Lax; break; + case CookieOptions.CookieOptionSameSite.Strict: cookieOptions.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Strict; break; + } + _cookies.Append(key, String.Join(',', values), cookieOptions); } diff --git a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj index 0fe76bf..0cb9234 100644 --- a/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj +++ b/Inversion.Web.AspNetCore/Inversion.Web.AspNetCore.csproj @@ -3,7 +3,7 @@ netcoreapp2.0 Inversion.Web.AspNetCore - 1.0.15 + 1.0.16 Adam Christie true @@ -14,7 +14,7 @@ - +