From af0923b68f6740d023ffdf039a9763fb217db65f Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 31 Jan 2014 13:25:12 -0800 Subject: [PATCH] Rouging out feature interfaces and default abstraction implementations --- HttpAbstractions.sln | 62 ++++-- .../MicrosoftOwinHttpContext.cs | 177 ---------------- .../OwinExtensions.cs | 22 -- .../RawOwinHttpContext.cs | 199 ------------------ .../project.json | 15 -- .../HttpContext.cs | 12 +- .../HttpRequest.cs | 6 - src/Microsoft.AspNet.Abstractions/IBuilder.cs | 7 +- .../AppBuilderSupportExtensions.cs | 41 ++++ .../ICanHasOwinEnvironment.cs | 9 + .../OwinConstants.cs | 0 .../OwinHttpEnvironment.cs | 13 +- .../project.json | 16 ++ ...faceDictionary.cs => FeatureCollection.cs} | 11 +- .../{InterfaceObject.cs => FeatureObject.cs} | 62 ++++-- ...aceDictionary.cs => IFeatureCollection.cs} | 2 +- .../HttpEnvironment.cs | 8 - .../IHttpEnvironment.cs | 8 - .../Properties/AssemblyInfo.cs | 36 ---- .../project.json | 9 - .../IHttpRequestInformation.cs | 7 +- .../IHttpTransportLayerSecurity.cs | 2 +- src/Microsoft.AspNet.PipelineCore/Builder.cs | 35 +-- .../DefaultCanHasItems.cs | 14 ++ .../DefaultCanHasQuery.cs | 37 ++++ .../DefaultCanHasRequestCookies.cs | 45 ++++ .../DefaultHttpContext.cs | 38 +++- .../DefaultHttpRequest.cs | 101 ++++----- .../DefaultHttpResponse.cs | 37 ++-- .../ICanHasItems.cs | 9 + .../ICanHasQuery.cs | 9 + .../ICanHasRequestCookies.cs | 9 + .../Infrastructure/FeatureReference.cs | 41 ++++ .../Infrastructure/ParsingHelpers.cs | 29 +-- ...Microsoft.AspNet.PipelineCore.net45.csproj | 10 +- .../RequestCookiesCollection.cs | 65 ++++++ .../AppBuilderSupportTests.cs | 43 ++++ .../OwinHttpEnvironmentTests.cs | 50 +++++ .../project.json | 23 ++ .../IThing.cs | 7 + ...{Class1.cs => InterfaceDictionaryTests.cs} | 19 +- ...Microsoft.AspNet.FeatureModel.Tests.csproj | 66 ------ .../Thing.cs | 10 + .../project.json | 17 ++ .../project.json | 23 ++ 45 files changed, 711 insertions(+), 750 deletions(-) delete mode 100644 src/Microsoft.AspNet.Abstractions.Owin/MicrosoftOwinHttpContext.cs delete mode 100644 src/Microsoft.AspNet.Abstractions.Owin/OwinExtensions.cs delete mode 100644 src/Microsoft.AspNet.Abstractions.Owin/RawOwinHttpContext.cs delete mode 100644 src/Microsoft.AspNet.Abstractions.Owin/project.json create mode 100644 src/Microsoft.AspNet.AppBuilderSupport/AppBuilderSupportExtensions.cs create mode 100644 src/Microsoft.AspNet.AppBuilderSupport/ICanHasOwinEnvironment.cs rename src/{Microsoft.AspNet.PipelineCore/Owin => Microsoft.AspNet.AppBuilderSupport}/OwinConstants.cs (100%) rename src/{Microsoft.AspNet.PipelineCore/Owin => Microsoft.AspNet.AppBuilderSupport}/OwinHttpEnvironment.cs (95%) create mode 100644 src/Microsoft.AspNet.AppBuilderSupport/project.json rename src/Microsoft.AspNet.FeatureModel/{InterfaceDictionary.cs => FeatureCollection.cs} (94%) rename src/Microsoft.AspNet.FeatureModel/{InterfaceObject.cs => FeatureObject.cs} (60%) rename src/Microsoft.AspNet.FeatureModel/{IInterfaceDictionary.cs => IFeatureCollection.cs} (62%) delete mode 100644 src/Microsoft.AspNet.HttpEnvironment/HttpEnvironment.cs delete mode 100644 src/Microsoft.AspNet.HttpEnvironment/IHttpEnvironment.cs delete mode 100644 src/Microsoft.AspNet.HttpEnvironment/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNet.HttpEnvironment/project.json create mode 100644 src/Microsoft.AspNet.PipelineCore/DefaultCanHasItems.cs create mode 100644 src/Microsoft.AspNet.PipelineCore/DefaultCanHasQuery.cs create mode 100644 src/Microsoft.AspNet.PipelineCore/DefaultCanHasRequestCookies.cs create mode 100644 src/Microsoft.AspNet.PipelineCore/ICanHasItems.cs create mode 100644 src/Microsoft.AspNet.PipelineCore/ICanHasQuery.cs create mode 100644 src/Microsoft.AspNet.PipelineCore/ICanHasRequestCookies.cs create mode 100644 src/Microsoft.AspNet.PipelineCore/Infrastructure/FeatureReference.cs create mode 100644 src/Microsoft.AspNet.PipelineCore/RequestCookiesCollection.cs create mode 100644 test/Microsoft.AspNet.AppBuilderSupport.Tests/AppBuilderSupportTests.cs create mode 100644 test/Microsoft.AspNet.AppBuilderSupport.Tests/OwinHttpEnvironmentTests.cs create mode 100644 test/Microsoft.AspNet.AppBuilderSupport.Tests/project.json create mode 100644 test/Microsoft.AspNet.FeatureModel.Tests/IThing.cs rename test/Microsoft.AspNet.FeatureModel.Tests/{Class1.cs => InterfaceDictionaryTests.cs} (76%) delete mode 100644 test/Microsoft.AspNet.FeatureModel.Tests/Microsoft.AspNet.FeatureModel.Tests.csproj create mode 100644 test/Microsoft.AspNet.FeatureModel.Tests/Thing.cs create mode 100644 test/Microsoft.AspNet.FeatureModel.Tests/project.json create mode 100644 test/Microsoft.AspNet.PipelineCore.Tests/project.json diff --git a/HttpAbstractions.sln b/HttpAbstractions.sln index c223d6618e..52bda0a4c2 100644 --- a/HttpAbstractions.sln +++ b/HttpAbstractions.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.FeatureModel.Tests", "test\Microsoft.AspNet.FeatureModel.Tests\Microsoft.AspNet.FeatureModel.Tests.csproj", "{8C671AE3-1188-499F-A2A2-3A0B117B33CE}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Abstractions.net45", "src\Microsoft.AspNet.Abstractions\Microsoft.AspNet.Abstractions.net45.csproj", "{659F2FD7-D44F-4953-A69D-94AF3D41BA21}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Abstractions.k10", "src\Microsoft.AspNet.Abstractions\Microsoft.AspNet.Abstractions.k10.csproj", "{7A5C31E4-97FD-479F-8938-D818436ADFDD}" @@ -21,26 +19,32 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.PipelineCo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.PipelineCore.k10", "src\Microsoft.AspNet.PipelineCore\Microsoft.AspNet.PipelineCore.k10.csproj", "{E31CF247-FDA9-4007-B194-A7DBAC18532C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Abstractions.Owin.net45", "src\Microsoft.AspNet.Abstractions.Owin\Microsoft.AspNet.Abstractions.Owin.net45.csproj", "{E6B7056F-547E-4B96-9E58-858DDDAE75D3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Abstractions.Owin.k10", "src\Microsoft.AspNet.Abstractions.Owin\Microsoft.AspNet.Abstractions.Owin.k10.csproj", "{C5C104A4-EE38-4D77-AC77-DF599FD5443A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A5A15F1C-885A-452A-A731-B0173DDBD913}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k10", "k10", "{ADDAE1B2-094E-4DA8-86DE-13E8708072D8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{4B39A6DA-68BD-4F50-BE76-0399EB82DCBF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.AppBuilderSupport.net45", "src\Microsoft.AspNet.AppBuilderSupport\Microsoft.AspNet.AppBuilderSupport.net45.csproj", "{C2E0CB24-159D-422F-B8D1-ACA7353B5C44}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F31FF137-390C-49BF-A3BD-7C6ED3597C21}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.AppBuilderSupport.Tests.net45", "test\Microsoft.AspNet.AppBuilderSupport.Tests\Microsoft.AspNet.AppBuilderSupport.Tests.net45.csproj", "{9DF61BB6-65EC-466B-8A86-FA1CE1F1DA03}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{04077455-D4A2-43AF-ABA2-E68968856E17}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k10", "k10", "{8C87E051-8A68-439A-A6C3-B16948126606}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.FeatureModel.Tests.net45", "test\Microsoft.AspNet.FeatureModel.Tests\Microsoft.AspNet.FeatureModel.Tests.net45.csproj", "{4C82EE1A-9B93-4374-91E0-75476AABF5CD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.PipelineCore.Tests.net45", "test\Microsoft.AspNet.PipelineCore.Tests\Microsoft.AspNet.PipelineCore.Tests.net45.csproj", "{00A03235-B248-4079-A7EE-4F77AB3A84E4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8C671AE3-1188-499F-A2A2-3A0B117B33CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8C671AE3-1188-499F-A2A2-3A0B117B33CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8C671AE3-1188-499F-A2A2-3A0B117B33CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8C671AE3-1188-499F-A2A2-3A0B117B33CE}.Release|Any CPU.Build.0 = Release|Any CPU {659F2FD7-D44F-4953-A69D-94AF3D41BA21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {659F2FD7-D44F-4953-A69D-94AF3D41BA21}.Debug|Any CPU.Build.0 = Debug|Any CPU {659F2FD7-D44F-4953-A69D-94AF3D41BA21}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -73,14 +77,22 @@ Global {E31CF247-FDA9-4007-B194-A7DBAC18532C}.Debug|Any CPU.Build.0 = Debug|Any CPU {E31CF247-FDA9-4007-B194-A7DBAC18532C}.Release|Any CPU.ActiveCfg = Release|Any CPU {E31CF247-FDA9-4007-B194-A7DBAC18532C}.Release|Any CPU.Build.0 = Release|Any CPU - {E6B7056F-547E-4B96-9E58-858DDDAE75D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E6B7056F-547E-4B96-9E58-858DDDAE75D3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E6B7056F-547E-4B96-9E58-858DDDAE75D3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E6B7056F-547E-4B96-9E58-858DDDAE75D3}.Release|Any CPU.Build.0 = Release|Any CPU - {C5C104A4-EE38-4D77-AC77-DF599FD5443A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C5C104A4-EE38-4D77-AC77-DF599FD5443A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C5C104A4-EE38-4D77-AC77-DF599FD5443A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C5C104A4-EE38-4D77-AC77-DF599FD5443A}.Release|Any CPU.Build.0 = Release|Any CPU + {C2E0CB24-159D-422F-B8D1-ACA7353B5C44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2E0CB24-159D-422F-B8D1-ACA7353B5C44}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2E0CB24-159D-422F-B8D1-ACA7353B5C44}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2E0CB24-159D-422F-B8D1-ACA7353B5C44}.Release|Any CPU.Build.0 = Release|Any CPU + {9DF61BB6-65EC-466B-8A86-FA1CE1F1DA03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9DF61BB6-65EC-466B-8A86-FA1CE1F1DA03}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9DF61BB6-65EC-466B-8A86-FA1CE1F1DA03}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9DF61BB6-65EC-466B-8A86-FA1CE1F1DA03}.Release|Any CPU.Build.0 = Release|Any CPU + {4C82EE1A-9B93-4374-91E0-75476AABF5CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C82EE1A-9B93-4374-91E0-75476AABF5CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C82EE1A-9B93-4374-91E0-75476AABF5CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C82EE1A-9B93-4374-91E0-75476AABF5CD}.Release|Any CPU.Build.0 = Release|Any CPU + {00A03235-B248-4079-A7EE-4F77AB3A84E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00A03235-B248-4079-A7EE-4F77AB3A84E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00A03235-B248-4079-A7EE-4F77AB3A84E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00A03235-B248-4079-A7EE-4F77AB3A84E4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -88,15 +100,19 @@ Global GlobalSection(NestedProjects) = preSolution {ADDAE1B2-094E-4DA8-86DE-13E8708072D8} = {A5A15F1C-885A-452A-A731-B0173DDBD913} {4B39A6DA-68BD-4F50-BE76-0399EB82DCBF} = {A5A15F1C-885A-452A-A731-B0173DDBD913} - {7A5C31E4-97FD-479F-8938-D818436ADFDD} = {ADDAE1B2-094E-4DA8-86DE-13E8708072D8} - {C5C104A4-EE38-4D77-AC77-DF599FD5443A} = {ADDAE1B2-094E-4DA8-86DE-13E8708072D8} {D3242B56-EA73-4F41-86A4-DF6C70271592} = {ADDAE1B2-094E-4DA8-86DE-13E8708072D8} {3A586BF4-08D4-46E3-B74D-5D514A3B84CC} = {ADDAE1B2-094E-4DA8-86DE-13E8708072D8} {E31CF247-FDA9-4007-B194-A7DBAC18532C} = {ADDAE1B2-094E-4DA8-86DE-13E8708072D8} - {659F2FD7-D44F-4953-A69D-94AF3D41BA21} = {4B39A6DA-68BD-4F50-BE76-0399EB82DCBF} - {E6B7056F-547E-4B96-9E58-858DDDAE75D3} = {4B39A6DA-68BD-4F50-BE76-0399EB82DCBF} - {70095525-BD99-45F9-8A6A-3BD3503FC3EE} = {4B39A6DA-68BD-4F50-BE76-0399EB82DCBF} + {7A5C31E4-97FD-479F-8938-D818436ADFDD} = {ADDAE1B2-094E-4DA8-86DE-13E8708072D8} {8A6EE89E-8ACC-44C1-8B1E-D2FB4C7189EE} = {4B39A6DA-68BD-4F50-BE76-0399EB82DCBF} {A195DDE4-CFB0-4A6C-9798-10658236C97B} = {4B39A6DA-68BD-4F50-BE76-0399EB82DCBF} + {659F2FD7-D44F-4953-A69D-94AF3D41BA21} = {4B39A6DA-68BD-4F50-BE76-0399EB82DCBF} + {70095525-BD99-45F9-8A6A-3BD3503FC3EE} = {4B39A6DA-68BD-4F50-BE76-0399EB82DCBF} + {C2E0CB24-159D-422F-B8D1-ACA7353B5C44} = {4B39A6DA-68BD-4F50-BE76-0399EB82DCBF} + {04077455-D4A2-43AF-ABA2-E68968856E17} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21} + {8C87E051-8A68-439A-A6C3-B16948126606} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21} + {9DF61BB6-65EC-466B-8A86-FA1CE1F1DA03} = {04077455-D4A2-43AF-ABA2-E68968856E17} + {4C82EE1A-9B93-4374-91E0-75476AABF5CD} = {04077455-D4A2-43AF-ABA2-E68968856E17} + {00A03235-B248-4079-A7EE-4F77AB3A84E4} = {04077455-D4A2-43AF-ABA2-E68968856E17} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.Abstractions.Owin/MicrosoftOwinHttpContext.cs b/src/Microsoft.AspNet.Abstractions.Owin/MicrosoftOwinHttpContext.cs deleted file mode 100644 index c648b66a55..0000000000 --- a/src/Microsoft.AspNet.Abstractions.Owin/MicrosoftOwinHttpContext.cs +++ /dev/null @@ -1,177 +0,0 @@ -#if NET45 -using System; -using System.IO; -using System.Threading.Tasks; -using Microsoft.AspNet.Abstractions; -using Microsoft.Owin; - -namespace Microsoft.AspNet.Abstractions.Owin -{ - public class MicrosoftOwinHttpContext : HttpContext - { - private readonly IOwinContext _context; - private readonly HttpRequest _request; - private readonly HttpResponse _response; - - public MicrosoftOwinHttpContext(IOwinContext context) - { - _context = context; - _request = new OwinHttpRequest(this, context.Request); - _response = new OwinHttpResponse(this, context.Response); - } - - public override void Dispose() - { - - } - - public override object GetInterface(Type type) - { - return null; - } - - public override HttpRequest Request - { - get { return _request; } - } - - public override HttpResponse Response - { - get { return _response; } - } - - public override void SetInterface(Type type, object instance) - { - - } - - private class OwinHttpRequest : HttpRequest - { - private HttpContext _context; - private IOwinRequest _request; - - public OwinHttpRequest(HttpContext context, IOwinRequest request) - { - _context = context; - _request = request; - } - - public override Stream Body - { - get - { - return _request.Body; - } - set - { - _request.Body = value; - } - } - - public override HttpContext HttpContext - { - get { return _context; } - } - - public override Microsoft.AspNet.Abstractions.PathString Path - { - get - { - return new Microsoft.AspNet.Abstractions.PathString(_request.Path.Value); - } - set - { - _request.Path = new Microsoft.Owin.PathString(value.Value); - } - } - - public override Microsoft.AspNet.Abstractions.PathString PathBase - { - get - { - return new Microsoft.AspNet.Abstractions.PathString(_request.PathBase.Value); - } - set - { - _request.PathBase = new Microsoft.Owin.PathString(value.Value); - } - } - - public override Microsoft.AspNet.Abstractions.QueryString QueryString - { - get - { - return new Microsoft.AspNet.Abstractions.QueryString(_request.QueryString.Value); - } - set - { - _request.QueryString = new Microsoft.Owin.QueryString(value.Value); - } - } - - public override Uri Uri - { - get { return _request.Uri; } - } - } - - private class OwinHttpResponse : HttpResponse - { - private readonly HttpContext _context; - private readonly IOwinResponse _response; - - public OwinHttpResponse(HttpContext context, IOwinResponse response) - { - _context = context; - _response = response; - } - - public override Stream Body - { - get - { - return _response.Body; - } - set - { - _response.Body = value; - } - } - - public override string ContentType - { - get - { - return _response.ContentType; - } - set - { - _response.ContentType = value; - } - } - - public override HttpContext HttpContext - { - get { return _context; } - } - - public override int StatusCode - { - get - { - return _response.StatusCode; - } - set - { - _response.StatusCode = value; - } - } - - public override Task WriteAsync(string data) - { - return _response.WriteAsync(data); - } - } - } -} -#endif \ No newline at end of file diff --git a/src/Microsoft.AspNet.Abstractions.Owin/OwinExtensions.cs b/src/Microsoft.AspNet.Abstractions.Owin/OwinExtensions.cs deleted file mode 100644 index 87788e5f93..0000000000 --- a/src/Microsoft.AspNet.Abstractions.Owin/OwinExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -#if NET45 -using System; -using System.Threading.Tasks; -using Microsoft.AspNet.Abstractions; -using Microsoft.AspNet.Abstractions.Owin; - -namespace Owin -{ - public static class OwinExtensions - { - public static void RunHttpContext(this IAppBuilder app, Func handler) - { - app.Run(context => - { - var httpContext = new MicrosoftOwinHttpContext(context); - - return handler(httpContext); - }); - } - } -} -#endif \ No newline at end of file diff --git a/src/Microsoft.AspNet.Abstractions.Owin/RawOwinHttpContext.cs b/src/Microsoft.AspNet.Abstractions.Owin/RawOwinHttpContext.cs deleted file mode 100644 index 69ea2e695b..0000000000 --- a/src/Microsoft.AspNet.Abstractions.Owin/RawOwinHttpContext.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Threading.Tasks; - -namespace Microsoft.AspNet.Abstractions.Owin -{ - public class RawOwinHttpContext : HttpContext - { - private readonly HttpRequest _request; - private readonly HttpResponse _response; - - public RawOwinHttpContext(IDictionary env) - { - _request = new RawOwinHttpRequest(this, env); - _response = new RawOwinHttpResponse(this, env); - } - - public override void Dispose() - { - - } - - public override object GetInterface(Type type) - { - return null; - } - - public override HttpRequest Request - { - get { return _request; } - } - - public override HttpResponse Response - { - get { return _response; } - } - - public override void SetInterface(Type type, object instance) - { - - } - - private class RawOwinHttpRequest : HttpRequest - { - private HttpContext _context; - private readonly IDictionary _env; - - public RawOwinHttpRequest(HttpContext context, IDictionary env) - { - _context = context; - _env = env; - } - - public override Stream Body - { - get - { - return (Stream)_env["owin.ResponseBody"]; - } - set - { - _env["owin.ResponseBody"] = value; - } - } - - public override HttpContext HttpContext - { - get { return _context; } - } - - public override PathString Path - { - get - { - return new PathString((string)_env["owin.RequestPath"]); - } - set - { - _env["owin.RequestPath"] = value.Value; - } - } - - public override PathString PathBase - { - get - { - return new PathString((string)_env["owin.RequestPathBase"]); - } - set - { - _env["owin.RequestPathBase"] = value.Value; - } - } - - public override QueryString QueryString - { - get - { - return new QueryString((string)_env["owin.RequestQueryString"]); - } - set - { - _env["owin.RequestQueryString"] = value.Value; - } - } - - public override Uri Uri - { - get - { - // TODO: Implement this sometime - throw new NotImplementedException(); - } - } - } - - private class RawOwinHttpResponse : HttpResponse - { - private readonly HttpContext _context; - private readonly IDictionary _env; - - public RawOwinHttpResponse(HttpContext context, IDictionary env) - { - _context = context; - _env = env; - } - - public override Stream Body - { - get - { - return (Stream)_env["owin.ResponseBody"]; - } - set - { - _env["owin.ResponseBody"] = value; - } - } - - public override string ContentType - { - get - { - return GetHeader("Content-Type"); - } - set - { - SetHeader("Content-Type", value); - } - } - - public override HttpContext HttpContext - { - get { return _context; } - } - - public override int StatusCode - { - get - { - return (int)_env["owin.ResponseStatusCode"]; - } - set - { - _env["owin.ResponseStatusCode"] = value; - } - } - - public override Task WriteAsync(string data) - { - var bytes = Encoding.UTF8.GetBytes(data); - - return Body.WriteAsync(bytes, 0, bytes.Length); - } - - private void SetHeader(string name, string value) - { - var headers = (IDictionary)_env["owin.ResponseHeaders"]; - - headers[name] = new[] { value }; - } - - private string GetHeader(string name) - { - var headers = (IDictionary)_env["owin.ResponseHeaders"]; - - string[] values; - if (headers.TryGetValue(name, out values) && values.Length > 0) - { - return values[0]; - } - - return null; - } - } - } -} diff --git a/src/Microsoft.AspNet.Abstractions.Owin/project.json b/src/Microsoft.AspNet.Abstractions.Owin/project.json deleted file mode 100644 index 991e11d3d8..0000000000 --- a/src/Microsoft.AspNet.Abstractions.Owin/project.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "0.1-alpha-*", - "dependencies": { - "Microsoft.AspNet.Abstractions": "" - }, - "configurations": { - "net45": { - "dependencies": { - "Owin": "1.0", - "Microsoft.Owin": "2.1.0" - } - }, - "k10": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Abstractions/HttpContext.cs b/src/Microsoft.AspNet.Abstractions/HttpContext.cs index ab1193bd44..03d8c7ec2e 100644 --- a/src/Microsoft.AspNet.Abstractions/HttpContext.cs +++ b/src/Microsoft.AspNet.Abstractions/HttpContext.cs @@ -13,18 +13,18 @@ namespace Microsoft.AspNet.Abstractions public abstract void Dispose(); - public abstract object GetInterface(Type type); + public abstract object GetFeature(Type type); - public abstract void SetInterface(Type type, object instance); + public abstract void SetFeature(Type type, object instance); - public virtual T GetInterface() + public virtual T GetFeature() { - return (T)GetInterface(typeof(T)); + return (T)GetFeature(typeof(T)); } - public virtual void SetInterface(T instance) + public virtual void SetFeature(T instance) { - SetInterface(typeof(T), instance); + SetFeature(typeof(T), instance); } } } diff --git a/src/Microsoft.AspNet.Abstractions/HttpRequest.cs b/src/Microsoft.AspNet.Abstractions/HttpRequest.cs index 40a7860af5..f7b85de29d 100644 --- a/src/Microsoft.AspNet.Abstractions/HttpRequest.cs +++ b/src/Microsoft.AspNet.Abstractions/HttpRequest.cs @@ -58,12 +58,6 @@ namespace Microsoft.AspNet.Abstractions /// The query value collection parsed from owin.RequestQueryString. public abstract IReadableStringCollection Query { get; } - /// - /// Gets the uniform resource identifier (URI) associated with the request. - /// - /// The uniform resource identifier (URI) associated with the request. - public abstract Uri Uri { get; } - /// /// Gets or set the owin.RequestProtocol. /// diff --git a/src/Microsoft.AspNet.Abstractions/IBuilder.cs b/src/Microsoft.AspNet.Abstractions/IBuilder.cs index c82f759739..778e98d404 100644 --- a/src/Microsoft.AspNet.Abstractions/IBuilder.cs +++ b/src/Microsoft.AspNet.Abstractions/IBuilder.cs @@ -2,14 +2,15 @@ using System; namespace Microsoft.AspNet.Abstractions { - public interface IBuilder + public interface IBuilder { - IBuilder Use(object middleware, params object[] args); + IBuilder Use(Func middleware); + IBuilder Run(RequestDelegate handler); IBuilder New(); RequestDelegate Build(); - object GetItem(Type type); + object GetItem(Type type); void SetItem(Type type, object feature); } } diff --git a/src/Microsoft.AspNet.AppBuilderSupport/AppBuilderSupportExtensions.cs b/src/Microsoft.AspNet.AppBuilderSupport/AppBuilderSupportExtensions.cs new file mode 100644 index 0000000000..d434c85b97 --- /dev/null +++ b/src/Microsoft.AspNet.AppBuilderSupport/AppBuilderSupportExtensions.cs @@ -0,0 +1,41 @@ +using Microsoft.AspNet.Abstractions; +using Microsoft.AspNet.PipelineCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNet.FeatureModel; +using Microsoft.AspNet.PipelineCore.Owin; + +namespace Owin +{ + using AppFunc = Func, Task>; + + public static class AppBuilderSupportExtensions + { + public static IAppBuilder UseBuilder(this IAppBuilder appBuilder, Action configuration) + { + IBuilder builder = new Builder(); + configuration(builder); + Func middleware1 = next1 => { + Func middleware2 = next2 => { + return httpContext => { + return next1(httpContext.GetFeature().Environment); + }; + }; + builder.Use(middleware2); + var app = builder.Build(); + return env => + { + return app.Invoke( + new DefaultHttpContext( + new FeatureCollection( + new FeatureObject( + new OwinHttpEnvironment(env))))); + }; + }; + return appBuilder.Use(middleware1); + } + } +} diff --git a/src/Microsoft.AspNet.AppBuilderSupport/ICanHasOwinEnvironment.cs b/src/Microsoft.AspNet.AppBuilderSupport/ICanHasOwinEnvironment.cs new file mode 100644 index 0000000000..37632116bd --- /dev/null +++ b/src/Microsoft.AspNet.AppBuilderSupport/ICanHasOwinEnvironment.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Microsoft.AspNet.PipelineCore.Owin +{ + public interface ICanHasOwinEnvironment + { + IDictionary Environment { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PipelineCore/Owin/OwinConstants.cs b/src/Microsoft.AspNet.AppBuilderSupport/OwinConstants.cs similarity index 100% rename from src/Microsoft.AspNet.PipelineCore/Owin/OwinConstants.cs rename to src/Microsoft.AspNet.AppBuilderSupport/OwinConstants.cs diff --git a/src/Microsoft.AspNet.PipelineCore/Owin/OwinHttpEnvironment.cs b/src/Microsoft.AspNet.AppBuilderSupport/OwinHttpEnvironment.cs similarity index 95% rename from src/Microsoft.AspNet.PipelineCore/Owin/OwinHttpEnvironment.cs rename to src/Microsoft.AspNet.AppBuilderSupport/OwinHttpEnvironment.cs index c8013ed522..0fb7a5ea01 100644 --- a/src/Microsoft.AspNet.PipelineCore/Owin/OwinHttpEnvironment.cs +++ b/src/Microsoft.AspNet.AppBuilderSupport/OwinHttpEnvironment.cs @@ -9,12 +9,16 @@ using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.HttpFeature; -using Microsoft.AspNet.Interfaces; namespace Microsoft.AspNet.PipelineCore.Owin { public class OwinHttpEnvironment : - IHttpRequestInformation, IHttpResponseInformation, IHttpConnection, IHttpSendFile, IHttpTransportLayerSecurity + IHttpRequestInformation, + IHttpResponseInformation, + IHttpConnection, + IHttpSendFile, + IHttpTransportLayerSecurity, + ICanHasOwinEnvironment { public IDictionary Environment { get; set; } @@ -44,11 +48,6 @@ namespace Microsoft.AspNet.PipelineCore.Owin set { Prop("owin.RequestProtocol", value); } } - Uri IHttpRequestInformation.Uri - { - get { throw new NotImplementedException(); } - } - string IHttpRequestInformation.Scheme { get { return Prop("owin.RequestScheme"); } diff --git a/src/Microsoft.AspNet.AppBuilderSupport/project.json b/src/Microsoft.AspNet.AppBuilderSupport/project.json new file mode 100644 index 0000000000..c597c1a29a --- /dev/null +++ b/src/Microsoft.AspNet.AppBuilderSupport/project.json @@ -0,0 +1,16 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "Microsoft.AspNet.Abstractions": "0.1-alpha-*", + "Microsoft.AspNet.FeatureModel": "0.1-alpha-*", + "Microsoft.AspNet.PipelineCore": "0.1-alpha-*", + "Microsoft.AspNet.HttpFeature" : "" + }, + "configurations": { + "net45": { + "dependencies": { + "Owin": "1.0" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.FeatureModel/InterfaceDictionary.cs b/src/Microsoft.AspNet.FeatureModel/FeatureCollection.cs similarity index 94% rename from src/Microsoft.AspNet.FeatureModel/InterfaceDictionary.cs rename to src/Microsoft.AspNet.FeatureModel/FeatureCollection.cs index a0f31a2306..028a1c9477 100644 --- a/src/Microsoft.AspNet.FeatureModel/InterfaceDictionary.cs +++ b/src/Microsoft.AspNet.FeatureModel/FeatureCollection.cs @@ -6,19 +6,19 @@ using Microsoft.AspNet.FeatureModel.Implementation; namespace Microsoft.AspNet.FeatureModel { - public class InterfaceDictionary : IInterfaceDictionary + public class FeatureCollection : IFeatureCollection { - private readonly IInterfaceDictionary _defaults; + private readonly IFeatureCollection _defaults; private readonly IDictionary _featureByFeatureType = new Dictionary(); private readonly IDictionary _featureTypeByName = new Dictionary(); private readonly object _containerSync = new Object(); private int _containerRevision; - public InterfaceDictionary() + public FeatureCollection() { } - public InterfaceDictionary(IInterfaceDictionary defaults) + public FeatureCollection(IFeatureCollection defaults) { _defaults = defaults; } @@ -174,7 +174,8 @@ namespace Microsoft.AspNet.FeatureModel public bool TryGetValue(Type key, out object value) { - throw new NotImplementedException(); + value = GetInterface(key); + return value != null; } public object this[Type key] diff --git a/src/Microsoft.AspNet.FeatureModel/InterfaceObject.cs b/src/Microsoft.AspNet.FeatureModel/FeatureObject.cs similarity index 60% rename from src/Microsoft.AspNet.FeatureModel/InterfaceObject.cs rename to src/Microsoft.AspNet.FeatureModel/FeatureObject.cs index 4673cd9c44..7b662285b9 100644 --- a/src/Microsoft.AspNet.FeatureModel/InterfaceObject.cs +++ b/src/Microsoft.AspNet.FeatureModel/FeatureObject.cs @@ -1,16 +1,17 @@ using System; -using System.Reflection; using System.Collections; using System.Collections.Generic; +using System.Reflection; +using System.Linq; using Microsoft.AspNet.FeatureModel.Implementation; namespace Microsoft.AspNet.FeatureModel { - public class InterfaceObject : IInterfaceDictionary + public class FeatureObject : IFeatureCollection { private readonly object _instance; - public InterfaceObject(object instance) + public FeatureObject(object instance) { _instance = instance; } @@ -31,7 +32,7 @@ namespace Microsoft.AspNet.FeatureModel { return _instance; } - + foreach (var interfaceType in _instance.GetType().GetInterfaces()) { if (interfaceType.FullName == type.FullName) @@ -55,7 +56,16 @@ namespace Microsoft.AspNet.FeatureModel public IEnumerator> GetEnumerator() { - throw new NotImplementedException(); + return GetTypeInterfaces() + .Select(interfaceType => new KeyValuePair(interfaceType, _instance)) + .GetEnumerator(); + } + + private IEnumerable GetTypeInterfaces() + { + return _instance.GetType() + .GetTypeInfo() + .ImplementedInterfaces; } IEnumerator IEnumerable.GetEnumerator() @@ -80,7 +90,23 @@ namespace Microsoft.AspNet.FeatureModel public void CopyTo(KeyValuePair[] array, int arrayIndex) { - throw new NotImplementedException(); + var enumerator = GetTypeInterfaces().GetEnumerator(); + for (var index = 0; index != arrayIndex; ++index) + { + if (!enumerator.MoveNext()) + { + throw new IndexOutOfRangeException(); + } + } + + for (var index = 0; index != array.Length; ++index) + { + if (!enumerator.MoveNext()) + { + throw new IndexOutOfRangeException(); + } + array[index] = new KeyValuePair(enumerator.Current, _instance); + } } public bool Remove(KeyValuePair item) @@ -90,17 +116,17 @@ namespace Microsoft.AspNet.FeatureModel public int Count { - get { throw new NotImplementedException(); } + get { return GetTypeInterfaces().Count(); } } public bool IsReadOnly { - get { throw new NotImplementedException(); } + get { return true; } } public bool ContainsKey(Type key) { - throw new NotImplementedException(); + return key.GetTypeInfo().IsAssignableFrom(_instance.GetType().GetTypeInfo()); } public void Add(Type key, object value) @@ -115,23 +141,33 @@ namespace Microsoft.AspNet.FeatureModel public bool TryGetValue(Type key, out object value) { - throw new NotImplementedException(); + value = GetInterface(key); + return value != null; } public object this[Type key] { - get { throw new NotImplementedException(); } + get { return GetInterface(key); } set { throw new NotImplementedException(); } } public ICollection Keys { - get { throw new NotImplementedException(); } + get { return GetTypeInterfaces().ToArray(); } } public ICollection Values { - get { throw new NotImplementedException(); } + get + { + var length = GetTypeInterfaces().Count(); + var array = new object[length]; + for (var index = 0; index != length; ++index) + { + array[index] = _instance; + } + return array; + } } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.FeatureModel/IInterfaceDictionary.cs b/src/Microsoft.AspNet.FeatureModel/IFeatureCollection.cs similarity index 62% rename from src/Microsoft.AspNet.FeatureModel/IInterfaceDictionary.cs rename to src/Microsoft.AspNet.FeatureModel/IFeatureCollection.cs index 18d07e7937..af70e6c2d7 100644 --- a/src/Microsoft.AspNet.FeatureModel/IInterfaceDictionary.cs +++ b/src/Microsoft.AspNet.FeatureModel/IFeatureCollection.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Microsoft.AspNet.FeatureModel { - public interface IInterfaceDictionary : IDictionary, IDisposable + public interface IFeatureCollection : IDictionary, IDisposable { int Revision { get; } } diff --git a/src/Microsoft.AspNet.HttpEnvironment/HttpEnvironment.cs b/src/Microsoft.AspNet.HttpEnvironment/HttpEnvironment.cs deleted file mode 100644 index 5836b621e9..0000000000 --- a/src/Microsoft.AspNet.HttpEnvironment/HttpEnvironment.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Microsoft.AspNet.FeatureModel; - -namespace Microsoft.AspNet.HttpEnvironment -{ - public abstract class HttpEnvironment : InterfaceDictionary, IHttpEnvironment - { - } -} diff --git a/src/Microsoft.AspNet.HttpEnvironment/IHttpEnvironment.cs b/src/Microsoft.AspNet.HttpEnvironment/IHttpEnvironment.cs deleted file mode 100644 index 8c4b99eda5..0000000000 --- a/src/Microsoft.AspNet.HttpEnvironment/IHttpEnvironment.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Microsoft.AspNet.FeatureModel; - -namespace Microsoft.AspNet.HttpEnvironment -{ - public interface IHttpEnvironment : IInterfaceDictionary - { - } -} diff --git a/src/Microsoft.AspNet.HttpEnvironment/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.HttpEnvironment/Properties/AssemblyInfo.cs deleted file mode 100644 index d68b8666f2..0000000000 --- a/src/Microsoft.AspNet.HttpEnvironment/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("Microsoft.AspNet.Environments")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.AspNet.Environments")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[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("1b326e9f-7c7a-42cd-9861-cdbef8353aed")] - -// 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("0.1.0")] -[assembly: AssemblyVersion("0.1.0")] -[assembly: AssemblyFileVersion("0.1.0")] diff --git a/src/Microsoft.AspNet.HttpEnvironment/project.json b/src/Microsoft.AspNet.HttpEnvironment/project.json deleted file mode 100644 index bea3db51c3..0000000000 --- a/src/Microsoft.AspNet.HttpEnvironment/project.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNet.FeatureModel" : "" - }, - "configurations": { - "net45": { }, - "k10" : { } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.HttpFeature/IHttpRequestInformation.cs b/src/Microsoft.AspNet.HttpFeature/IHttpRequestInformation.cs index 424c06f940..a293218830 100644 --- a/src/Microsoft.AspNet.HttpFeature/IHttpRequestInformation.cs +++ b/src/Microsoft.AspNet.HttpFeature/IHttpRequestInformation.cs @@ -14,6 +14,11 @@ namespace Microsoft.AspNet.HttpFeature string QueryString { get; set; } IDictionary Headers { get; set; } Stream Body { get; set; } - Uri Uri { get; } + // FURI: Uri Uri { get; } + } + + public interface ICanHasSession + { + } } diff --git a/src/Microsoft.AspNet.HttpFeature/IHttpTransportLayerSecurity.cs b/src/Microsoft.AspNet.HttpFeature/IHttpTransportLayerSecurity.cs index a08136b6aa..7a27df9b6c 100644 --- a/src/Microsoft.AspNet.HttpFeature/IHttpTransportLayerSecurity.cs +++ b/src/Microsoft.AspNet.HttpFeature/IHttpTransportLayerSecurity.cs @@ -12,4 +12,4 @@ namespace Microsoft.AspNet.HttpFeature #endif Task LoadAsync(); } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNet.PipelineCore/Builder.cs b/src/Microsoft.AspNet.PipelineCore/Builder.cs index 26068cf03e..8e4d2f0ac0 100644 --- a/src/Microsoft.AspNet.PipelineCore/Builder.cs +++ b/src/Microsoft.AspNet.PipelineCore/Builder.cs @@ -9,17 +9,17 @@ namespace Microsoft.AspNet.PipelineCore { public class Builder : IBuilder { - private readonly IInterfaceDictionary _interfaces; + private readonly IFeatureCollection _interfaces; private readonly IDictionary _properties; - private readonly IList _components = new List(); + private readonly IList> _components = new List>(); public Builder() { - _interfaces = new InterfaceDictionary(); + _interfaces = new FeatureCollection(); _properties = new Dictionary(); } - public Builder(IInterfaceDictionary interfaces, IDictionary properties) + public Builder(IFeatureCollection interfaces, IDictionary properties) { _interfaces = interfaces; _properties = properties; @@ -52,22 +52,15 @@ namespace Microsoft.AspNet.PipelineCore _properties[key] = value; } - public IBuilder Use(object middleware, params object[] args) + public IBuilder Use(Func middleware) { - _components.Add(new Entry(middleware, args)); + _components.Add(middleware); return this; } - class Entry + public IBuilder Run(RequestDelegate handler) { - private readonly object _middleware; - private readonly object[] _args; - - public Entry(object middleware, object[] args) - { - _middleware = middleware; - _args = args; - } + return Use(next => handler); } public IBuilder New() @@ -81,20 +74,10 @@ namespace Microsoft.AspNet.PipelineCore foreach (var component in _components.Reverse()) { - app = Activate(component, app); + app = component(app); } return app; } - - private RequestDelegate Activate(Entry component, RequestDelegate app) - { - return app; - } - - public Func Adapt(object app) - { - return null; - } } } diff --git a/src/Microsoft.AspNet.PipelineCore/DefaultCanHasItems.cs b/src/Microsoft.AspNet.PipelineCore/DefaultCanHasItems.cs new file mode 100644 index 0000000000..31e41440bb --- /dev/null +++ b/src/Microsoft.AspNet.PipelineCore/DefaultCanHasItems.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace Microsoft.AspNet.PipelineCore +{ + public class DefaultCanHasItems : ICanHasItems + { + public DefaultCanHasItems() + { + Items = new Dictionary(); + } + + public IDictionary Items { get; private set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PipelineCore/DefaultCanHasQuery.cs b/src/Microsoft.AspNet.PipelineCore/DefaultCanHasQuery.cs new file mode 100644 index 0000000000..7e97670db1 --- /dev/null +++ b/src/Microsoft.AspNet.PipelineCore/DefaultCanHasQuery.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using Microsoft.AspNet.Abstractions; +using Microsoft.AspNet.FeatureModel; +using Microsoft.AspNet.HttpFeature; +using Microsoft.AspNet.PipelineCore.Collections; +using Microsoft.AspNet.PipelineCore.Infrastructure; + +namespace Microsoft.AspNet.PipelineCore +{ + public class DefaultCanHasQuery : ICanHasQuery + { + private readonly IFeatureCollection _features; + private FeatureReference _request = new FeatureReference(); + private string _queryString; + private IReadableStringCollection _query; + + public DefaultCanHasQuery(IFeatureCollection features) + { + _features = features; + } + + public IReadableStringCollection Query + { + get + { + var queryString = _request.Fetch(_features).QueryString; + if (_query == null || _queryString != queryString) + { + _queryString = queryString; + // TODO + _query = new ReadableStringCollection(new Dictionary()); + } + return _query; + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PipelineCore/DefaultCanHasRequestCookies.cs b/src/Microsoft.AspNet.PipelineCore/DefaultCanHasRequestCookies.cs new file mode 100644 index 0000000000..f4d23e029e --- /dev/null +++ b/src/Microsoft.AspNet.PipelineCore/DefaultCanHasRequestCookies.cs @@ -0,0 +1,45 @@ +using System; +using Microsoft.AspNet.Abstractions; +using Microsoft.AspNet.FeatureModel; +using Microsoft.AspNet.HttpFeature; +using Microsoft.AspNet.PipelineCore.Infrastructure; + +namespace Microsoft.AspNet.PipelineCore +{ + public class DefaultCanHasRequestCookies : ICanHasRequestCookies + { + private readonly IFeatureCollection _features; + private FeatureReference _request = new FeatureReference(); + private string _cookiesHeader; + private RequestCookiesCollection _cookiesCollection; + private static readonly string[] ZeroHeaders = new string[0]; + + public DefaultCanHasRequestCookies(IFeatureCollection features) + { + _features = features; + } + + public IReadableStringCollection Cookies + { + get + { + var headers = _request.Fetch(_features).Headers; + string cookiesHeader = ParsingHelpers.GetHeader(headers, "Cookies") ?? ""; + + if (_cookiesCollection == null) + { + _cookiesCollection = new RequestCookiesCollection(); + _cookiesCollection.Reparse(cookiesHeader); + _cookiesHeader = cookiesHeader; + } + else if (!string.Equals(_cookiesHeader, cookiesHeader, StringComparison.Ordinal)) + { + _cookiesCollection.Reparse(cookiesHeader); + _cookiesHeader = cookiesHeader; + } + + return _cookiesCollection; + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PipelineCore/DefaultHttpContext.cs b/src/Microsoft.AspNet.PipelineCore/DefaultHttpContext.cs index f5a85826d7..4dc7adf253 100644 --- a/src/Microsoft.AspNet.PipelineCore/DefaultHttpContext.cs +++ b/src/Microsoft.AspNet.PipelineCore/DefaultHttpContext.cs @@ -1,43 +1,59 @@ using System; +using System.Collections.Generic; using Microsoft.AspNet.Abstractions; using Microsoft.AspNet.FeatureModel; +using Microsoft.AspNet.PipelineCore.Infrastructure; namespace Microsoft.AspNet.PipelineCore { public class DefaultHttpContext : HttpContext { - private readonly IInterfaceDictionary _environment; private readonly HttpRequest _request; private readonly HttpResponse _response; - public DefaultHttpContext(IInterfaceDictionary environment) + private FeatureReference _canHasItems; + private IFeatureCollection _features; + + public DefaultHttpContext(IFeatureCollection features) { - _environment = environment; - _request = new DefaultHttpRequest(this); - _response = new DefaultHttpResponse(this); + _features = features; + _request = new DefaultHttpRequest(this, features); + _response = new DefaultHttpResponse(this, features); + + _canHasItems = new FeatureReference(); + } + + ICanHasItems CanHasItems + { + get { return _canHasItems.Fetch(_features) ?? _canHasItems.Update(_features, new DefaultCanHasItems()); } } public override HttpRequest Request { get { return _request; } } public override HttpResponse Response { get { return _response; } } - public int Revision { get { return _environment.Revision; } } + public override IDictionary Items + { + get { return CanHasItems.Items; } + } + + public int Revision { get { return _features.Revision; } } public override void Dispose() { // REVIEW: is this necessary? is the environment "owned" by the context? - _environment.Dispose(); + _features.Dispose(); } - public override object GetInterface(Type type) + public override object GetFeature(Type type) { object value; - return _environment.TryGetValue(type, out value) ? value : null; + return _features.TryGetValue(type, out value) ? value : null; } - public override void SetInterface(Type type, object instance) + public override void SetFeature(Type type, object instance) { - _environment[type] = instance; + _features[type] = instance; } } } diff --git a/src/Microsoft.AspNet.PipelineCore/DefaultHttpRequest.cs b/src/Microsoft.AspNet.PipelineCore/DefaultHttpRequest.cs index 4a5be161e2..055af55c49 100644 --- a/src/Microsoft.AspNet.PipelineCore/DefaultHttpRequest.cs +++ b/src/Microsoft.AspNet.PipelineCore/DefaultHttpRequest.cs @@ -1,98 +1,91 @@ using System; using System.IO; using Microsoft.AspNet.Abstractions; +using Microsoft.AspNet.FeatureModel; using Microsoft.AspNet.HttpFeature; -using Microsoft.AspNet.Interfaces; +using Microsoft.AspNet.PipelineCore.Infrastructure; namespace Microsoft.AspNet.PipelineCore { public class DefaultHttpRequest : HttpRequest { private readonly DefaultHttpContext _context; - private int _revision; - private IHttpRequestInformation _request; - private IHttpConnection _connection; + private readonly IFeatureCollection _features; - public DefaultHttpRequest(DefaultHttpContext context) + private FeatureReference _request = new FeatureReference(); + private FeatureReference _connection = new FeatureReference(); + private FeatureReference _transportLayerSecurity = new FeatureReference(); + private FeatureReference _canHasQuery = new FeatureReference(); + private FeatureReference _canHasCookies = new FeatureReference(); + + public DefaultHttpRequest(DefaultHttpContext context, IFeatureCollection features) { _context = context; + _features = features; } - private IHttpRequestInformation IHttpRequest + private IHttpRequestInformation HttpRequestInformation { - get { return EnsureCurrent(_request) ?? (_request = _context.GetInterface()); } + get { return _request.Fetch(_features); } } - private IHttpConnection IHttpConnection + private IHttpConnection HttpConnection { - get { return EnsureCurrent(_connection) ?? (_connection = _context.GetInterface()); } + get { return _connection.Fetch(_features); } } - private T EnsureCurrent(T feature) where T : class + private IHttpTransportLayerSecurity HttpTransportLayerSecurity { - if (_revision == _context.Revision) return feature; + get { return _transportLayerSecurity.Fetch(_features); } + } + + private ICanHasQuery CanHasQuery + { + get { return _canHasQuery.Fetch(_features) ?? _canHasQuery.Update(_features, new DefaultCanHasQuery(_features)); } + } + + private ICanHasRequestCookies CanHasRequestCookies + { + get { return _canHasCookies.Fetch(_features) ?? _canHasCookies.Update(_features, new DefaultCanHasRequestCookies(_features)); } + } - _request = null; - _connection = null; - _revision = _context.Revision; - return null; - } public override HttpContext HttpContext { get { return _context; } } - public override Uri Uri - { - get { return IHttpRequest.Uri; } - } - - //public override Uri Uri { get { _request} } - public override PathString PathBase { - get { return new PathString(IHttpRequest.PathBase); } - set { IHttpRequest.PathBase = value.Value; } + get { return new PathString(HttpRequestInformation.PathBase); } + set { HttpRequestInformation.PathBase = value.Value; } } public override PathString Path { - get { return new PathString(IHttpRequest.Path); } - set { IHttpRequest.Path = value.Value; } + get { return new PathString(HttpRequestInformation.Path); } + set { HttpRequestInformation.Path = value.Value; } } public override QueryString QueryString { - get { return new QueryString(IHttpRequest.QueryString); } - set { IHttpRequest.QueryString = value.Value; } + get { return new QueryString(HttpRequestInformation.QueryString); } + set { HttpRequestInformation.QueryString = value.Value; } } public override Stream Body { - get { return IHttpRequest.Body; } - set { IHttpRequest.Body = value; } + get { return HttpRequestInformation.Body; } + set { HttpRequestInformation.Body = value; } } public override string Method { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } + get { return HttpRequestInformation.Method; } + set { HttpRequestInformation.Method = value; } } public override string Scheme { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } + get { return HttpRequestInformation.Scheme; } + set { HttpRequestInformation.Scheme = value; } } public override bool IsSecure @@ -114,19 +107,13 @@ namespace Microsoft.AspNet.PipelineCore public override IReadableStringCollection Query { - get { throw new NotImplementedException(); } + get { return CanHasQuery.Query; } } public override string Protocol { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } + get { return HttpRequestInformation.Protocol; } + set { HttpRequestInformation.Protocol = value; } } public override IHeaderDictionary Headers @@ -136,7 +123,7 @@ namespace Microsoft.AspNet.PipelineCore public override IReadableStringCollection Cookies { - get { throw new NotImplementedException(); } + get { return CanHasRequestCookies.Cookies; } } public override System.Threading.CancellationToken CallCanceled diff --git a/src/Microsoft.AspNet.PipelineCore/DefaultHttpResponse.cs b/src/Microsoft.AspNet.PipelineCore/DefaultHttpResponse.cs index 4b4f61e620..614005692a 100644 --- a/src/Microsoft.AspNet.PipelineCore/DefaultHttpResponse.cs +++ b/src/Microsoft.AspNet.PipelineCore/DefaultHttpResponse.cs @@ -2,56 +2,53 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Abstractions; +using Microsoft.AspNet.FeatureModel; using Microsoft.AspNet.HttpFeature; -using Microsoft.AspNet.HttpFeature.Security; +using Microsoft.AspNet.PipelineCore.Infrastructure; namespace Microsoft.AspNet.PipelineCore { public class DefaultHttpResponse : HttpResponse { private readonly DefaultHttpContext _context; - private IHttpResponseInformation _response; - private int _revision; + private readonly IFeatureCollection _features; + private FeatureReference _response = FeatureReference.Default; - public DefaultHttpResponse(DefaultHttpContext context) + public DefaultHttpResponse(DefaultHttpContext context, IFeatureCollection features) { _context = context; + _features = features; } - private IHttpResponseInformation IHttpResponse + private IHttpResponseInformation HttpResponseInformation { - get { return EnsureCurrent(_response) ?? (_response = _context.GetInterface()); } - } - - private T EnsureCurrent(T feature) where T : class - { - if (_revision == _context.Revision) return feature; - - _response = null; - _revision = _context.Revision; - return null; + get { return _response.Fetch(_features); } } public override HttpContext HttpContext { get { return _context; } } public override int StatusCode { - get { return IHttpResponse.StatusCode; } - set { IHttpResponse.StatusCode = value; } + get { return HttpResponseInformation.StatusCode; } + set { HttpResponseInformation.StatusCode = value; } } - public override Stream Body { get { return _response.Body; } set { _response.Body = value; } } + public override Stream Body + { + get { return HttpResponseInformation.Body; } + set { HttpResponseInformation.Body = value; } + } public override string ContentType { get { - var contentTypeValues = IHttpResponse.Headers["Content-Type"]; + var contentTypeValues = HttpResponseInformation.Headers["Content-Type"]; return contentTypeValues.Length == 0 ? null : contentTypeValues[0]; } set { - IHttpResponse.Headers["Content-Type"] = new[] { value }; + HttpResponseInformation.Headers["Content-Type"] = new[] { value }; } } diff --git a/src/Microsoft.AspNet.PipelineCore/ICanHasItems.cs b/src/Microsoft.AspNet.PipelineCore/ICanHasItems.cs new file mode 100644 index 0000000000..d1adbf6030 --- /dev/null +++ b/src/Microsoft.AspNet.PipelineCore/ICanHasItems.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Microsoft.AspNet.PipelineCore +{ + public interface ICanHasItems + { + IDictionary Items { get; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PipelineCore/ICanHasQuery.cs b/src/Microsoft.AspNet.PipelineCore/ICanHasQuery.cs new file mode 100644 index 0000000000..570ef1c2d2 --- /dev/null +++ b/src/Microsoft.AspNet.PipelineCore/ICanHasQuery.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNet.Abstractions; + +namespace Microsoft.AspNet.PipelineCore +{ + public interface ICanHasQuery + { + IReadableStringCollection Query { get; } + } +} diff --git a/src/Microsoft.AspNet.PipelineCore/ICanHasRequestCookies.cs b/src/Microsoft.AspNet.PipelineCore/ICanHasRequestCookies.cs new file mode 100644 index 0000000000..8bc138fbf5 --- /dev/null +++ b/src/Microsoft.AspNet.PipelineCore/ICanHasRequestCookies.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNet.Abstractions; + +namespace Microsoft.AspNet.PipelineCore +{ + public interface ICanHasRequestCookies + { + IReadableStringCollection Cookies { get; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PipelineCore/Infrastructure/FeatureReference.cs b/src/Microsoft.AspNet.PipelineCore/Infrastructure/FeatureReference.cs new file mode 100644 index 0000000000..70aba473a5 --- /dev/null +++ b/src/Microsoft.AspNet.PipelineCore/Infrastructure/FeatureReference.cs @@ -0,0 +1,41 @@ +using Microsoft.AspNet.FeatureModel; + +namespace Microsoft.AspNet.PipelineCore.Infrastructure +{ + internal struct FeatureReference + { + private T _feature; + private int _revision; + + private FeatureReference(T feature, int revision) + { + _feature = feature; + _revision = revision; + } + + public static readonly FeatureReference Default = new FeatureReference(default(T), -1); + + public T Fetch(IFeatureCollection features) + { + if (_revision == features.Revision) return _feature; + object value; + if (features.TryGetValue(typeof(T), out value)) + { + _feature = (T)value; + } + else + { + _feature = default(T); + } + _revision = features.Revision; + return _feature; + } + + public T Update(IFeatureCollection features, T feature) + { + features[typeof(T)] = _feature = feature; + _revision = features.Revision; + return feature; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PipelineCore/Infrastructure/ParsingHelpers.cs b/src/Microsoft.AspNet.PipelineCore/Infrastructure/ParsingHelpers.cs index 0a9a581ec2..91254955f7 100644 --- a/src/Microsoft.AspNet.PipelineCore/Infrastructure/ParsingHelpers.cs +++ b/src/Microsoft.AspNet.PipelineCore/Infrastructure/ParsingHelpers.cs @@ -545,6 +545,11 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure return cookies; } + internal static void ParseCookies(string cookiesHeader, IDictionary cookiesCollection) + { + ParseDelimited(cookiesHeader, SemicolonAndComma, AddCookieCallback, cookiesCollection); + } + internal static void ParseDelimited(string text, char[] delimiters, Action callback, object state) { int textLength = text.Length; @@ -851,19 +856,19 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure internal static partial class ParsingHelpers { - internal static string GetHost(HttpRequest request) - { - IHeaderDictionary headers = request.Headers; + //internal static string GetHost(HttpRequest request) + //{ + // IHeaderDictionary headers = request.Headers; - string host = GetHeader(headers, "Host"); - if (!string.IsNullOrWhiteSpace(host)) - { - return host; - } + // string host = GetHeader(headers, "Host"); + // if (!string.IsNullOrWhiteSpace(host)) + // { + // return host; + // } - string localIpAddress = request.LocalIpAddress ?? "localhost"; - var localPort = request.Get(OwinConstants.CommonKeys.LocalPort); - return string.IsNullOrWhiteSpace(localPort) ? localIpAddress : (localIpAddress + ":" + localPort); - } + // string localIpAddress = request.LocalIpAddress ?? "localhost"; + // var localPort = request.Get(OwinConstants.CommonKeys.LocalPort); + // return string.IsNullOrWhiteSpace(localPort) ? localIpAddress : (localIpAddress + ":" + localPort); + //} } } diff --git a/src/Microsoft.AspNet.PipelineCore/Microsoft.AspNet.PipelineCore.net45.csproj b/src/Microsoft.AspNet.PipelineCore/Microsoft.AspNet.PipelineCore.net45.csproj index 9c9e6c6f47..9844b7f087 100644 --- a/src/Microsoft.AspNet.PipelineCore/Microsoft.AspNet.PipelineCore.net45.csproj +++ b/src/Microsoft.AspNet.PipelineCore/Microsoft.AspNet.PipelineCore.net45.csproj @@ -41,18 +41,24 @@ + + + + + + + + - - diff --git a/src/Microsoft.AspNet.PipelineCore/RequestCookiesCollection.cs b/src/Microsoft.AspNet.PipelineCore/RequestCookiesCollection.cs new file mode 100644 index 0000000000..0f84ea704f --- /dev/null +++ b/src/Microsoft.AspNet.PipelineCore/RequestCookiesCollection.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Microsoft.AspNet.Abstractions; +using Microsoft.AspNet.PipelineCore.Infrastructure; + +namespace Microsoft.AspNet.PipelineCore +{ + public class RequestCookiesCollection : IReadableStringCollection + { + private readonly IDictionary _dictionary; + + public RequestCookiesCollection() + { + _dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); + } + + public IEnumerator> GetEnumerator() + { + foreach (var pair in _dictionary) + { + yield return new KeyValuePair(pair.Key, new[] { pair.Value }); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public string this[string key] + { + get { return Get(key); } + } + + public string Get(string key) + { + string value; + return _dictionary.TryGetValue(key, out value) ? value : null; + } + + public IList GetValues(string key) + { + string value; + return _dictionary.TryGetValue(key, out value) ? new[] { value } : null; + } + + private static readonly char[] SemicolonAndComma = { ';', ',' }; + + public void Reparse(string cookiesHeader) + { + _dictionary.Clear(); + ParsingHelpers.ParseDelimited(cookiesHeader, SemicolonAndComma, AddCookieCallback, _dictionary); + } + + private static readonly Action AddCookieCallback = (name, value, state) => + { + var dictionary = (IDictionary)state; + if (!dictionary.ContainsKey(name)) + { + dictionary.Add(name, value); + } + }; + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.AppBuilderSupport.Tests/AppBuilderSupportTests.cs b/test/Microsoft.AspNet.AppBuilderSupport.Tests/AppBuilderSupportTests.cs new file mode 100644 index 0000000000..4b2c70872d --- /dev/null +++ b/test/Microsoft.AspNet.AppBuilderSupport.Tests/AppBuilderSupportTests.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Runtime.Remoting.Contexts; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNet.Abstractions; +using Owin; +using Xunit; + +namespace Microsoft.AspNet.AppBuilderSupport.Tests +{ + public class AppBuilderSupportTests + { + [Fact] + public async Task BuildCanGoInsideAppBuilder() + { + var server = Microsoft.Owin.Testing.TestServer.Create( + app => app.UseBuilder(HelloWorld)); + + var result = await server.CreateRequest("/hello").GetAsync(); + var body = await result.Content.ReadAsStringAsync(); + + Assert.Equal(result.StatusCode, HttpStatusCode.Accepted); + Assert.Equal(body, "Hello world!"); + } + + private void HelloWorld(IBuilder builder) + { + builder.Use(next => async context => + { + await next(context); + }); + builder.Run(async context => + { + context.Response.StatusCode = 202; + await context.Response.WriteAsync("Hello world!"); + }); + } + } +} diff --git a/test/Microsoft.AspNet.AppBuilderSupport.Tests/OwinHttpEnvironmentTests.cs b/test/Microsoft.AspNet.AppBuilderSupport.Tests/OwinHttpEnvironmentTests.cs new file mode 100644 index 0000000000..5b639a6a0c --- /dev/null +++ b/test/Microsoft.AspNet.AppBuilderSupport.Tests/OwinHttpEnvironmentTests.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNet.FeatureModel; +using Microsoft.AspNet.HttpFeature; +using Microsoft.AspNet.PipelineCore.Owin; +using Xunit; + +namespace Microsoft.AspNet.AppBuilderSupport.Tests +{ + public class OwinHttpEnvironmentTests + { + private T Get(IFeatureCollection features) + { + object value; + return features.TryGetValue(typeof(T), out value) ? (T)value : default(T); + } + + [Fact] + public void OwinHttpEnvironmentCanBeCreated() + { + var env = new Dictionary + { + {"owin.RequestMethod", "POST"} + }; + var features = new FeatureObject( new OwinHttpEnvironment(env)); + + Assert.Equal(Get(features).Method, "POST"); + } + + [Fact] + public void ImplementedInterfacesAreEnumerated() + { + var env = new Dictionary + { + {"owin.RequestMethod", "POST"} + }; + var features = new FeatureObject(new OwinHttpEnvironment(env)); + + var entries = features.ToArray(); + var keys = features.Keys.ToArray(); + var values = features.Values.ToArray(); + + Assert.Contains(typeof(IHttpRequestInformation), keys); + Assert.Contains(typeof(IHttpResponseInformation), keys); + } + } +} diff --git a/test/Microsoft.AspNet.AppBuilderSupport.Tests/project.json b/test/Microsoft.AspNet.AppBuilderSupport.Tests/project.json new file mode 100644 index 0000000000..3ff0961905 --- /dev/null +++ b/test/Microsoft.AspNet.AppBuilderSupport.Tests/project.json @@ -0,0 +1,23 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "Microsoft.AspNet.AppBuilderSupport": "", + "Microsoft.AspNet.HttpFeature": "", + "Microsoft.AspNet.Abstractions": "", + "Microsoft.AspNet.FeatureModel": "" + }, + "configurations": { + "net45": { + "dependencies": { + "Owin": "1.0", + "Microsoft.Owin": "2.1.0", + "Microsoft.Owin.Hosting": "2.1.0", + "Microsoft.Owin.Testing": "2.1.0", + "Shouldly": "1.1.1.1", + "xunit": "1.9.2", + "Microsoft.Net.Http": "2.2.13", + "System.Net.Http": "" + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.FeatureModel.Tests/IThing.cs b/test/Microsoft.AspNet.FeatureModel.Tests/IThing.cs new file mode 100644 index 0000000000..0a4a213540 --- /dev/null +++ b/test/Microsoft.AspNet.FeatureModel.Tests/IThing.cs @@ -0,0 +1,7 @@ +namespace Microsoft.AspNet.FeatureModel.Tests +{ + public interface IThing + { + string Hello(); + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.FeatureModel.Tests/Class1.cs b/test/Microsoft.AspNet.FeatureModel.Tests/InterfaceDictionaryTests.cs similarity index 76% rename from test/Microsoft.AspNet.FeatureModel.Tests/Class1.cs rename to test/Microsoft.AspNet.FeatureModel.Tests/InterfaceDictionaryTests.cs index 7527e07ffc..c42f4b37d1 100644 --- a/test/Microsoft.AspNet.FeatureModel.Tests/Class1.cs +++ b/test/Microsoft.AspNet.FeatureModel.Tests/InterfaceDictionaryTests.cs @@ -4,25 +4,12 @@ using Xunit; namespace Microsoft.AspNet.FeatureModel.Tests { - public interface IThing - { - string Hello(); - } - - public class Thing : IThing - { - public string Hello() - { - return "World"; - } - } - public class InterfaceDictionaryTests { [Fact] public void AddedInterfaceIsReturned() { - var interfaces = new InterfaceDictionary(); + var interfaces = new FeatureCollection(); var thing = new Thing(); interfaces.Add(typeof(IThing), thing); @@ -37,7 +24,7 @@ namespace Microsoft.AspNet.FeatureModel.Tests [Fact] public void IndexerAlsoAddsItems() { - var interfaces = new InterfaceDictionary(); + var interfaces = new FeatureCollection(); var thing = new Thing(); interfaces[typeof(IThing)] = thing; @@ -52,7 +39,7 @@ namespace Microsoft.AspNet.FeatureModel.Tests [Fact] public void SecondCallToAddThrowsException() { - var interfaces = new InterfaceDictionary(); + var interfaces = new FeatureCollection(); var thing = new Thing(); interfaces.Add(typeof(IThing), thing); diff --git a/test/Microsoft.AspNet.FeatureModel.Tests/Microsoft.AspNet.FeatureModel.Tests.csproj b/test/Microsoft.AspNet.FeatureModel.Tests/Microsoft.AspNet.FeatureModel.Tests.csproj deleted file mode 100644 index 5f11f27e55..0000000000 --- a/test/Microsoft.AspNet.FeatureModel.Tests/Microsoft.AspNet.FeatureModel.Tests.csproj +++ /dev/null @@ -1,66 +0,0 @@ - - - - - Debug - AnyCPU - {8C671AE3-1188-499F-A2A2-3A0B117B33CE} - Library - Properties - Microsoft.AspNet.FeatureModel.Tests - Microsoft.AspNet.FeatureModel.Tests - v4.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\packages\Shouldly.1.1.1.1\lib\35\Shouldly.dll - - - - - ..\..\packages\xunit.1.9.2\lib\net20\xunit.dll - - - - - - - - - - - - {95aee59d-bf51-47cb-a957-c03d909cc148} - Microsoft.AspNet.FeatureModel.net45 - - - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNet.FeatureModel.Tests/Thing.cs b/test/Microsoft.AspNet.FeatureModel.Tests/Thing.cs new file mode 100644 index 0000000000..c99a8b1909 --- /dev/null +++ b/test/Microsoft.AspNet.FeatureModel.Tests/Thing.cs @@ -0,0 +1,10 @@ +namespace Microsoft.AspNet.FeatureModel.Tests +{ + public class Thing : IThing + { + public string Hello() + { + return "World"; + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.FeatureModel.Tests/project.json b/test/Microsoft.AspNet.FeatureModel.Tests/project.json new file mode 100644 index 0000000000..e52db7c2c2 --- /dev/null +++ b/test/Microsoft.AspNet.FeatureModel.Tests/project.json @@ -0,0 +1,17 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "Microsoft.AspNet.AppBuilderSupport": "", + "Microsoft.AspNet.HttpFeature": "", + "Microsoft.AspNet.Abstractions": "", + "Microsoft.AspNet.FeatureModel": "" + }, + "configurations": { + "net45": { + "dependencies": { + "Shouldly": "1.1.1.1", + "xunit": "1.9.2" + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.PipelineCore.Tests/project.json b/test/Microsoft.AspNet.PipelineCore.Tests/project.json new file mode 100644 index 0000000000..0a90b7ac74 --- /dev/null +++ b/test/Microsoft.AspNet.PipelineCore.Tests/project.json @@ -0,0 +1,23 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "Microsoft.AspNet.AppBuilderSupport": "", + "Microsoft.AspNet.HttpFeature": "", + "Microsoft.AspNet.Abstractions": "", + "Microsoft.AspNet.FeatureModel": "" + }, + "configurations": { + "net45": { + "dependencies": { + "Owin": "1.0", + "Microsoft.Owin": "2.1.0", + "Microsoft.Owin.Hosting": "2.1.0", + "Microsoft.Owin.Testing": "2.1.0", + "Moq": "4.2.1312.1622", + "xunit": "1.9.2", + "Microsoft.Net.Http": "2.2.13", + "System.Net.Http": "" + } + } + } +} \ No newline at end of file