diff --git a/Neptuo.sln b/Neptuo.sln index fb80a337..7bc33c36 100644 --- a/Neptuo.sln +++ b/Neptuo.sln @@ -24,10 +24,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neptuo.Windows.Threading", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsole", "test\TestConsole\TestConsole.csproj", "{A5BF3C46-5A9A-4151-BF55-9AF3EF1E3146}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neptuo.Web.Routing", "src\Neptuo.Web.Routing\Neptuo.Web.Routing.csproj", "{45C70782-7B22-4CDA-B8E4-9E71182E3A32}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestMvc4", "test\TestMvc4\TestMvc4.csproj", "{662F383E-7768-4A06-A8B9-DA15A73E4D47}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neptuo.Data", "src\Neptuo.Data\Neptuo.Data.csproj", "{304C75B0-88B0-4470-BD2D-FD7DB582BEBF}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neptuo.Data.Entity", "src\Neptuo.Data.Entity\Neptuo.Data.Entity.csproj", "{FEE06F1E-0063-4D46-85CE-7334CE61AFB0}" @@ -46,8 +42,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Windows", "Windows", "{A7CE EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{45933E25-016D-477C-964A-029C9FC7724E}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Web", "Web", "{AA724CB1-03F1-4FF2-A158-2E95524F67BC}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWpf", "test\TestWpf\TestWpf.csproj", "{834CEB47-4BCD-4895-80FA-44960472C64B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neptuo.Activators.Simple", "src\Neptuo.Activators.Simple\Neptuo.Activators.Simple.csproj", "{891F1607-D6F3-4D9F-8FF1-ABC9DA73B563}" @@ -198,14 +192,6 @@ Global {A5BF3C46-5A9A-4151-BF55-9AF3EF1E3146}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5BF3C46-5A9A-4151-BF55-9AF3EF1E3146}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5BF3C46-5A9A-4151-BF55-9AF3EF1E3146}.Release|Any CPU.Build.0 = Release|Any CPU - {45C70782-7B22-4CDA-B8E4-9E71182E3A32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {45C70782-7B22-4CDA-B8E4-9E71182E3A32}.Debug|Any CPU.Build.0 = Debug|Any CPU - {45C70782-7B22-4CDA-B8E4-9E71182E3A32}.Release|Any CPU.ActiveCfg = Release|Any CPU - {45C70782-7B22-4CDA-B8E4-9E71182E3A32}.Release|Any CPU.Build.0 = Release|Any CPU - {662F383E-7768-4A06-A8B9-DA15A73E4D47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {662F383E-7768-4A06-A8B9-DA15A73E4D47}.Debug|Any CPU.Build.0 = Debug|Any CPU - {662F383E-7768-4A06-A8B9-DA15A73E4D47}.Release|Any CPU.ActiveCfg = Release|Any CPU - {662F383E-7768-4A06-A8B9-DA15A73E4D47}.Release|Any CPU.Build.0 = Release|Any CPU {304C75B0-88B0-4470-BD2D-FD7DB582BEBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {304C75B0-88B0-4470-BD2D-FD7DB582BEBF}.Debug|Any CPU.Build.0 = Debug|Any CPU {304C75B0-88B0-4470-BD2D-FD7DB582BEBF}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -451,7 +437,6 @@ Global {2392ED97-E671-4871-81A4-C85975F33794} = {2CBC9170-F18E-4CAC-B9BA-860DB1625765} {0A82625A-BB41-48CE-B3AD-0141DD3CB779} = {A7CE8ABF-9770-49F4-8969-8AB6957A87E6} {6D0AD236-40F4-4734-8FC3-16E99C7BE2F4} = {A7CE8ABF-9770-49F4-8969-8AB6957A87E6} - {45C70782-7B22-4CDA-B8E4-9E71182E3A32} = {AA724CB1-03F1-4FF2-A158-2E95524F67BC} {304C75B0-88B0-4470-BD2D-FD7DB582BEBF} = {45933E25-016D-477C-964A-029C9FC7724E} {FEE06F1E-0063-4D46-85CE-7334CE61AFB0} = {45933E25-016D-477C-964A-029C9FC7724E} {671BF5EF-9E1C-4EF9-AE7C-57C9F960650B} = {5D0CB141-A610-4243-BBDA-7D5A9084FC53} diff --git a/src/Neptuo.Web.Routing/IRequiredRouteParameter.cs b/src/Neptuo.Web.Routing/IRequiredRouteParameter.cs deleted file mode 100644 index d1246651..00000000 --- a/src/Neptuo.Web.Routing/IRequiredRouteParameter.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing -{ - public interface IRequiredRouteParameter - { - bool IsRequired { get; } - } -} diff --git a/src/Neptuo.Web.Routing/IRouteParameter.cs b/src/Neptuo.Web.Routing/IRouteParameter.cs deleted file mode 100644 index 6d23db05..00000000 --- a/src/Neptuo.Web.Routing/IRouteParameter.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing -{ - public interface IRouteParameter - { - bool MatchUrl(IRouteParameterMatchContext context); - - - } -} diff --git a/src/Neptuo.Web.Routing/IRouteParameterContext.cs b/src/Neptuo.Web.Routing/IRouteParameterContext.cs deleted file mode 100644 index 688d69b1..00000000 --- a/src/Neptuo.Web.Routing/IRouteParameterContext.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Routing; - -namespace Neptuo.Web.Routing -{ - public interface IRouteParameterMatchContext - { - string OriginalUrl { get; } - RouteValueDictionary Values { get; } - - string RemainingUrl { get; set; } - } -} diff --git a/src/Neptuo.Web.Routing/IRouteParameterFactory.cs b/src/Neptuo.Web.Routing/IRouteParameterFactory.cs deleted file mode 100644 index 686f06bd..00000000 --- a/src/Neptuo.Web.Routing/IRouteParameterFactory.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; - -namespace Neptuo.Web.Routing -{ - public interface IRouteParameterFactory - { - IRouteParameter CreateParameter(HttpContextBase httpContext); - } -} diff --git a/src/Neptuo.Web.Routing/IRouteParameterRegistry.cs b/src/Neptuo.Web.Routing/IRouteParameterRegistry.cs deleted file mode 100644 index 12d995fd..00000000 --- a/src/Neptuo.Web.Routing/IRouteParameterRegistry.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing -{ - public interface IRouteParameterRegistry - { - IRouteParameterRegistry Add(string parameterName, IRouteParameter parameter); - IRouteParameterRegistry Add(string parameterName, IRouteParameterFactory factory); - } -} diff --git a/src/Neptuo.Web.Routing/IRouteParameterService.cs b/src/Neptuo.Web.Routing/IRouteParameterService.cs deleted file mode 100644 index 08b59257..00000000 --- a/src/Neptuo.Web.Routing/IRouteParameterService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing -{ - public interface IRouteParameterService - { - IRouteParameter Get(string parameterName); - } -} diff --git a/src/Neptuo.Web.Routing/Neptuo.Web.Routing.csproj b/src/Neptuo.Web.Routing/Neptuo.Web.Routing.csproj deleted file mode 100644 index ea0ddc99..00000000 --- a/src/Neptuo.Web.Routing/Neptuo.Web.Routing.csproj +++ /dev/null @@ -1,79 +0,0 @@ - - - - - Debug - AnyCPU - {45C70782-7B22-4CDA-B8E4-9E71182E3A32} - Library - Properties - Neptuo.Web.Routing - Neptuo.Web.Routing - v4.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {2392ed97-e671-4871-81a4-c85975f33794} - Neptuo - - - - - \ No newline at end of file diff --git a/src/Neptuo.Web.Routing/Properties/AssemblyInfo.cs b/src/Neptuo.Web.Routing/Properties/AssemblyInfo.cs deleted file mode 100644 index 6a38b420..00000000 --- a/src/Neptuo.Web.Routing/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Neptuo.Web.Routing; -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("Neptuo.Web.Routing")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Neptuo.Web.Routing")] -[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("c9417f80-f382-45db-bbfc-5da587b71ad4")] - -// 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(VersionInfo.Version)] -[assembly: AssemblyInformationalVersion(VersionInfo.Version)] -[assembly: AssemblyFileVersion(VersionInfo.Version)] diff --git a/src/Neptuo.Web.Routing/Properties/VersionInfo.cs b/src/Neptuo.Web.Routing/Properties/VersionInfo.cs deleted file mode 100644 index 62d6d458..00000000 --- a/src/Neptuo.Web.Routing/Properties/VersionInfo.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace Neptuo.Web.Routing -{ - public static class VersionInfo - { - internal const string Version = "1.2.1"; - - public static Version GetVersion() - { - return new Version(Version); - } - } -} diff --git a/src/Neptuo.Web.Routing/ProxyRouteParameter.cs b/src/Neptuo.Web.Routing/ProxyRouteParameter.cs deleted file mode 100644 index e2de78b5..00000000 --- a/src/Neptuo.Web.Routing/ProxyRouteParameter.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing -{ - public class ProxyRouteParameter : IRouteParameter - { - public static readonly char[] Separators = new char[] { '/', '.' }; - - public string Name { get; private set; } - - public ProxyRouteParameter(string name) - { - Name = name; - } - - public bool MatchUrl(IRouteParameterMatchContext context) - { - foreach (char separator in Separators) - { - int index = context.OriginalUrl.IndexOf(separator); - if (index > 0) - { - context.Values[Name] = context.OriginalUrl.Substring(0, index); - context.RemainingUrl = context.OriginalUrl.Substring(index); - return true; - } - } - - context.Values[Name] = context.OriginalUrl; - context.RemainingUrl = null; - return true; - } - } -} diff --git a/src/Neptuo.Web.Routing/RequiredRouteParameter.cs b/src/Neptuo.Web.Routing/RequiredRouteParameter.cs deleted file mode 100644 index 0053c63c..00000000 --- a/src/Neptuo.Web.Routing/RequiredRouteParameter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing -{ - public abstract class RequiredRouteParameter : IRouteParameter, IRequiredRouteParameter - { - public bool IsRequired { get; protected set; } - - public RequiredRouteParameter() - { - IsRequired = true; - } - - public bool MatchUrl(IRouteParameterMatchContext context) - { - if (IsRequired && String.IsNullOrEmpty(context.OriginalUrl)) - return false; - - return MatchRequiredUrl(context); - } - - public abstract bool MatchRequiredUrl(IRouteParameterMatchContext context); - - } -} diff --git a/src/Neptuo.Web.Routing/RouteParameters.cs b/src/Neptuo.Web.Routing/RouteParameters.cs deleted file mode 100644 index fa2d619c..00000000 --- a/src/Neptuo.Web.Routing/RouteParameters.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; - -namespace Neptuo.Web.Routing -{ - public class RouteParameters - { - private static IRouteParameterService service; - private static IRouteParameterRegistry registry; - - public static IRouteParameterService Service - { - get { return service; } - } - - public static IRouteParameterRegistry Registry - { - get { return registry; } - } - - static RouteParameters() - { - var defaultService = new DefaultRouteParameterService(); - service = defaultService; - registry = defaultService; - } - } - - internal class DefaultRouteParameterService : IRouteParameterService, IRouteParameterRegistry - { - private ConcurrentDictionary parameters = new ConcurrentDictionary(); - - public IRouteParameterRegistry Add(string parameterName, IRouteParameter parameter) - { - Ensure.NotNull(parameterName, "parameterName"); - Ensure.NotNull(parameter, "parameter"); - parameters[parameterName] = new ProxyRouteParameterFactory(parameter); - return this; - } - - public IRouteParameterRegistry Add(string parameterName, IRouteParameterFactory factory) - { - Ensure.NotNull(parameterName, "parameterName"); - Ensure.NotNull(factory, "factory"); - parameters[parameterName] = factory; - return this; - } - - public IRouteParameter Get(string parameterName) - { - Ensure.NotNull(parameterName, "parameterName"); - - IRouteParameterFactory parameter; - if (parameters.TryGetValue(parameterName, out parameter)) - return parameter.CreateParameter(new HttpContextWrapper(HttpContext.Current)); - - parameterName = parameterName.ToLowerInvariant(); - if (parameters.TryGetValue(parameterName, out parameter)) - return parameter.CreateParameter(new HttpContextWrapper(HttpContext.Current)); - - return new ProxyRouteParameter(parameterName); - } - } - - internal class ProxyRouteParameterFactory : IRouteParameterFactory - { - private IRouteParameter routeParameter; - - public ProxyRouteParameterFactory(IRouteParameter routeParameter) - { - this.routeParameter = routeParameter; - } - - public IRouteParameter CreateParameter(HttpContextBase httpContext) - { - return routeParameter; - } - } - -} diff --git a/src/Neptuo.Web.Routing/Segments/NamedRouteSegment.cs b/src/Neptuo.Web.Routing/Segments/NamedRouteSegment.cs deleted file mode 100644 index d1dd9333..00000000 --- a/src/Neptuo.Web.Routing/Segments/NamedRouteSegment.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing.Segments -{ - public abstract class NamedRouteSegment : RouteSegment - { - protected string Name { get; private set; } - - public NamedRouteSegment(string name) - { - Name = name; - } - } -} diff --git a/src/Neptuo.Web.Routing/Segments/ParamRouteSegment.cs b/src/Neptuo.Web.Routing/Segments/ParamRouteSegment.cs deleted file mode 100644 index 8605cc54..00000000 --- a/src/Neptuo.Web.Routing/Segments/ParamRouteSegment.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing.Segments -{ - public class ParamRouteSegment : RouteSegment - { - protected bool IsRequired { get; private set; } - protected IRouteParameter Parameter { get; private set; } - - public ParamRouteSegment(IRouteParameter parameter) - { - Ensure.NotNull(parameter, "parameter"); - Parameter = parameter; - - IRequiredRouteParameter requiredParameter = parameter as IRequiredRouteParameter; - IsRequired = requiredParameter != null && requiredParameter.IsRequired; - } - - public override bool MatchUrl(RouteSegmentContext context) - { - if (IsRequired && String.IsNullOrEmpty(context.OriginalUrl)) - return false; - - return Parameter.MatchUrl(context); - } - } -} diff --git a/src/Neptuo.Web.Routing/Segments/RequiredRouteSegment.cs b/src/Neptuo.Web.Routing/Segments/RequiredRouteSegment.cs deleted file mode 100644 index 0cb29805..00000000 --- a/src/Neptuo.Web.Routing/Segments/RequiredRouteSegment.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing.Segments -{ - public abstract class RequiredRouteSegment : RouteSegment - { - public override bool MatchUrl(RouteSegmentContext context) - { - if (String.IsNullOrEmpty(context.OriginalUrl)) - return false; - - return MatchRequiredUrl(context); - } - - public abstract bool MatchRequiredUrl(RouteSegmentContext context); - } -} diff --git a/src/Neptuo.Web.Routing/Segments/RouteSegment.cs b/src/Neptuo.Web.Routing/Segments/RouteSegment.cs deleted file mode 100644 index 5e5289c0..00000000 --- a/src/Neptuo.Web.Routing/Segments/RouteSegment.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Routing; - -namespace Neptuo.Web.Routing.Segments -{ - public abstract class RouteSegment - { - public abstract bool MatchUrl(RouteSegmentContext context); - } -} diff --git a/src/Neptuo.Web.Routing/Segments/RouteSegmentContext.cs b/src/Neptuo.Web.Routing/Segments/RouteSegmentContext.cs deleted file mode 100644 index de31ac4c..00000000 --- a/src/Neptuo.Web.Routing/Segments/RouteSegmentContext.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Routing; - -namespace Neptuo.Web.Routing.Segments -{ - public class RouteSegmentContext : IRouteParameterMatchContext - { - public string OriginalUrl { get; private set; } - public RouteValueDictionary Values { get; private set; } - - public string RemainingUrl { get; set; } - - public RouteSegmentContext(string originalUrl, RouteValueDictionary values) - { - OriginalUrl = originalUrl; - Values = values; - RemainingUrl = originalUrl; - } - } -} diff --git a/src/Neptuo.Web.Routing/Segments/StaticNamedRouteSegment.cs b/src/Neptuo.Web.Routing/Segments/StaticNamedRouteSegment.cs deleted file mode 100644 index ac6f67c3..00000000 --- a/src/Neptuo.Web.Routing/Segments/StaticNamedRouteSegment.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing.Segments -{ - public class StaticNamedRouteSegment : NamedRouteSegment - { - protected string Path { get; private set; } - - public StaticNamedRouteSegment(string name, string path) - : base(name) - { - Path = path; - } - - public override bool MatchUrl(RouteSegmentContext context) - { - if (context.OriginalUrl.StartsWith(Path)) - { - string value = context.OriginalUrl.Substring(0, Path.Length); - context.Values[Name] = value; - context.RemainingUrl = context.OriginalUrl.Substring(Path.Length); - return true; - } - return false; - } - } -} diff --git a/src/Neptuo.Web.Routing/Segments/StaticRouteSegment.cs b/src/Neptuo.Web.Routing/Segments/StaticRouteSegment.cs deleted file mode 100644 index 16d9e5d2..00000000 --- a/src/Neptuo.Web.Routing/Segments/StaticRouteSegment.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neptuo.Web.Routing.Segments -{ - public class StaticRouteSegment : RequiredRouteSegment - { - protected string Path { get; private set; } - - public StaticRouteSegment(string path) - { - Path = path; - } - - public override bool MatchRequiredUrl(RouteSegmentContext context) - { - if (context.OriginalUrl.StartsWith(Path)) - { - string value = context.OriginalUrl.Substring(0, Path.Length); - context.RemainingUrl = context.OriginalUrl.Substring(Path.Length); - return true; - } - return false; - } - } -} diff --git a/src/Neptuo.Web.Routing/TokenRoute.cs b/src/Neptuo.Web.Routing/TokenRoute.cs deleted file mode 100644 index dcfc64cd..00000000 --- a/src/Neptuo.Web.Routing/TokenRoute.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Neptuo.Text.Tokens; -using Neptuo.Web.Routing.Segments; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; -using System.Web.Routing; - -namespace Neptuo.Web.Routing -{ - public class TokenRoute : TokenRouteBase - { - protected List Segments { get; set; } - - public string Url { get; private set; } - - protected override bool IsAbsolute - { - get { return !Url.StartsWith("~/"); } - } - - public TokenRoute(string url, IRouteHandler routeHandler, string suffix = null, bool caseSensitive = false, IRouteParameterService parameterService = null) - : base(routeHandler, suffix, caseSensitive, parameterService) - { - Ensure.NotNull(url, "url"); - Url = url; - Segments = BuildRoute(Url); - } - - protected override bool MatchUrl(string url, RouteValueDictionary values) - { - if (!String.IsNullOrEmpty(Suffix) && !url.EndsWith(Suffix)) - return false; - - RouteSegmentContext context = new RouteSegmentContext(url, values); - foreach (RouteSegment segment in Segments) - { - if (!segment.MatchUrl(context)) - return false; - - context = new RouteSegmentContext(context.RemainingUrl, values); - } - - if (!MatchSuffix(context.RemainingUrl)) - return false; - - return true; - } - - protected override string GetRequestUrl(HttpContextBase httpContext) - { - if (IsAbsolute) - return httpContext.Request.Url.ToString(); - - return base.GetRequestUrl(httpContext); - } - - public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) - { - //throw new NotImplementedException(); - return null; - } - } -} diff --git a/src/Neptuo.Web.Routing/TokenRouteBase.cs b/src/Neptuo.Web.Routing/TokenRouteBase.cs deleted file mode 100644 index 8838a4a7..00000000 --- a/src/Neptuo.Web.Routing/TokenRouteBase.cs +++ /dev/null @@ -1,98 +0,0 @@ -using Neptuo.Text.Tokens; -using Neptuo.Web.Routing.Segments; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; -using System.Web.Routing; - -namespace Neptuo.Web.Routing -{ - public abstract class TokenRouteBase : RouteBase - { - protected TokenParser TokenParser { get; private set; } - protected IRouteParameterService ParameterService { get; private set; } - protected abstract bool IsAbsolute { get; } - - public IRouteHandler RouteHandler { get; set; } - public string Suffix { get; set; } - public bool CaseSensitive { get; set; } - - public TokenRouteBase(IRouteHandler routeHandler, string suffix = null, bool caseSensitive = false, IRouteParameterService parameterService = null) - { - Ensure.NotNull(routeHandler, "routeHandler"); - CaseSensitive = caseSensitive; - - RouteHandler = routeHandler; - Suffix = suffix; - ParameterService = parameterService ?? RouteParameters.Service; - TokenParser = CreateTokenParser(); - } - - protected virtual TokenParser CreateTokenParser() - { - TokenParser parser = new TokenParser(); - parser.Configuration.AllowTextContent = true; - return parser; - } - - protected virtual List BuildRoute(string routeUrl) - { - if (!CaseSensitive) - routeUrl = routeUrl.ToLowerInvariant(); - - List result = new List(); - - int lastIndex = 0; - TokenParser.OnParsedToken += (sender, e) => - { - if (e.StartPosition > lastIndex) - result.Add(new StaticRouteSegment(routeUrl.Substring(lastIndex, e.StartPosition - lastIndex))); - - result.Add(new ParamRouteSegment(ParameterService.Get(e.Token.Fullname))); - lastIndex = e.EndPosition + 1; - }; - - if (!TokenParser.Parse(routeUrl)) - throw Ensure.Exception.ArgumentOutOfRange("routeUrl", "Route url is not valid format for TokenRoute."); - - if (routeUrl.Length > lastIndex) - result.Add(new StaticRouteSegment(routeUrl.Substring(lastIndex))); - - return result; - } - - public override RouteData GetRouteData(HttpContextBase httpContext) - { - string requestUrl = GetRequestUrl(httpContext); - if (requestUrl == null) - return null; - - if (!CaseSensitive) - requestUrl = requestUrl.ToLowerInvariant(); - - RouteData routeData = new RouteData(this, RouteHandler); - if (MatchUrl(requestUrl, routeData.Values)) - return routeData; - - return null; - } - - protected virtual string GetRequestUrl(HttpContextBase httpContext) - { - return httpContext.Request.AppRelativeCurrentExecutionFilePath + httpContext.Request.PathInfo; - } - - protected abstract bool MatchUrl(string url, RouteValueDictionary values); - - protected virtual bool MatchSuffix(string remainingUrl) - { - if (Suffix == null) - return String.IsNullOrEmpty(remainingUrl); - - return Suffix == remainingUrl; - } - } -} diff --git a/src/Neptuo.Web.Routing/TreeTokenRoute.cs b/src/Neptuo.Web.Routing/TreeTokenRoute.cs deleted file mode 100644 index 1e2da91b..00000000 --- a/src/Neptuo.Web.Routing/TreeTokenRoute.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Routing; - -namespace Neptuo.Web.Routing -{ - public abstract class TreeTokenRoute : TokenRouteBase - { - public TreeTokenRoute(IRouteHandler routeHandler, string suffix = null, bool caseSensitive = false, IRouteParameterService parameterService = null) - : base(routeHandler, suffix, caseSensitive, parameterService) - { - throw new NotImplementedException(); - } - - protected override bool MatchUrl(string url, RouteValueDictionary values) - { - throw new NotImplementedException(); - } - - public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) - { - throw new NotImplementedException(); - } - - protected override bool IsAbsolute - { - get { throw new NotImplementedException(); } - } - } -} diff --git a/test/TestMvc4/App_Start/FilterConfig.cs b/test/TestMvc4/App_Start/FilterConfig.cs deleted file mode 100644 index 84e7b845..00000000 --- a/test/TestMvc4/App_Start/FilterConfig.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Web; -using System.Web.Mvc; - -namespace TestMvc4 -{ - public class FilterConfig - { - public static void RegisterGlobalFilters(GlobalFilterCollection filters) - { - filters.Add(new HandleErrorAttribute()); - } - } -} \ No newline at end of file diff --git a/test/TestMvc4/App_Start/RouteConfig.cs b/test/TestMvc4/App_Start/RouteConfig.cs deleted file mode 100644 index 28af3bf6..00000000 --- a/test/TestMvc4/App_Start/RouteConfig.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Neptuo.Web.Routing; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using System.Web.Routing; -using TestMvc4.Controllers; -using TestMvc4.Models; - -namespace TestMvc4 -{ - public class RouteConfig - { - public static void RegisterRoutes(RouteCollection routes) - { - //RouteParameters.Registry.Add("locale", new LocaleRouteParameter("cs-cz")); - - - - //routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); - - //routes.Add(new TokenRoute("~/text", new TestRouteHandler())); - //routes.Add(new TokenRoute("~/HelloWorld", new TestRouteHandler(), ".aspx")); - //routes.Add(new TokenRoute("~/{Locale}/HelloWorld", new TestRouteHandler())); - //routes.Add(new Route("{*pathInfo}", new TestRouteHandler(true))); - - //routes.MapRoute( - // name: "Default", - // url: "{controller}/{action}/{id}", - // defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } - //); - } - } -} \ No newline at end of file diff --git a/test/TestMvc4/App_Start/WebApiConfig.cs b/test/TestMvc4/App_Start/WebApiConfig.cs deleted file mode 100644 index 915b7028..00000000 --- a/test/TestMvc4/App_Start/WebApiConfig.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web.Http; - -namespace TestMvc4 -{ - public static class WebApiConfig - { - public static void Register(HttpConfiguration config) - { - config.Routes.MapHttpRoute( - name: "DefaultApi", - routeTemplate: "api/{controller}/{id}", - defaults: new { id = RouteParameter.Optional } - ); - } - } -} diff --git a/test/TestMvc4/Controllers/HomeController.cs b/test/TestMvc4/Controllers/HomeController.cs deleted file mode 100644 index ecc93656..00000000 --- a/test/TestMvc4/Controllers/HomeController.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; - -namespace TestMvc4.Controllers -{ - public class HomeController : Controller - { - // - // GET: /Home/ - - public ActionResult Index() - { - return View(); - } - - } -} diff --git a/test/TestMvc4/Controllers/TestHandler.cs b/test/TestMvc4/Controllers/TestHandler.cs deleted file mode 100644 index ca064a9e..00000000 --- a/test/TestMvc4/Controllers/TestHandler.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Routing; - -namespace TestMvc4.Controllers -{ - public class TestHandler : IHttpHandler - { - private bool notFound; - private RouteData routeData; - - public bool IsReusable - { - get { return true; } - } - - public TestHandler(bool notFound, RouteData routeData) - { - this.notFound = notFound; - this.routeData = routeData; - } - - public void ProcessRequest(HttpContext context) - { - context.Response.ContentType = "text/plain"; - if (notFound) - { - context.Response.Write("404 - Not Found"); - } - else - { - foreach (var item in routeData.Values) - context.Response.Write(String.Format("{0}: {1}{2}", item.Key, item.Value, Environment.NewLine)); - - if (routeData.DataTokens.ContainsKey("TemplateID")) - context.Response.Write(String.Format("TemplateID: {0}{1}", routeData.DataTokens["TemplateID"], Environment.NewLine)); - - context.Response.Write(context.Request.AppRelativeCurrentExecutionFilePath); - } - } - } -} \ No newline at end of file diff --git a/test/TestMvc4/Controllers/TestRouteHandler.cs b/test/TestMvc4/Controllers/TestRouteHandler.cs deleted file mode 100644 index 057bcdcb..00000000 --- a/test/TestMvc4/Controllers/TestRouteHandler.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Routing; - -namespace TestMvc4.Controllers -{ - public class TestRouteHandler : IRouteHandler - { - private bool notFound; - - public TestRouteHandler(bool notFound = false) - { - this.notFound = notFound; - } - - public IHttpHandler GetHttpHandler(RequestContext requestContext) - { - return new TestHandler(notFound, requestContext.RouteData); - } - } -} \ No newline at end of file diff --git a/test/TestMvc4/Global.asax b/test/TestMvc4/Global.asax deleted file mode 100644 index 4fb49c9c..00000000 --- a/test/TestMvc4/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="TestMvc4.MvcApplication" Language="C#" %> diff --git a/test/TestMvc4/Global.asax.cs b/test/TestMvc4/Global.asax.cs deleted file mode 100644 index b7cfddc2..00000000 --- a/test/TestMvc4/Global.asax.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Http; -using System.Web.Mvc; -using System.Web.Routing; - -namespace TestMvc4 -{ - // Note: For instructions on enabling IIS6 or IIS7 classic mode, - // visit http://go.microsoft.com/?LinkId=9394801 - public class MvcApplication : System.Web.HttpApplication - { - protected void Application_Start() - { - AreaRegistration.RegisterAllAreas(); - - WebApiConfig.Register(GlobalConfiguration.Configuration); - FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); - RouteConfig.RegisterRoutes(RouteTable.Routes); - } - } -} \ No newline at end of file diff --git a/test/TestMvc4/Models/LocaleRouteParameter.cs b/test/TestMvc4/Models/LocaleRouteParameter.cs deleted file mode 100644 index efac4a05..00000000 --- a/test/TestMvc4/Models/LocaleRouteParameter.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Neptuo.Globalization; -using Neptuo.Web.Routing; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Web; - -namespace TestMvc4.Models -{ - public class LocaleRouteParameter : IRouteParameter - { - private string defaultLocale; - - public LocaleRouteParameter(string defaultLocale) - { - this.defaultLocale = defaultLocale; - } - - public bool MatchUrl(IRouteParameterMatchContext context) - { - if (String.IsNullOrEmpty(context.OriginalUrl)) - { - if (!String.IsNullOrEmpty(defaultLocale)) - { - context.Values["locale"] = CultureInfo.GetCultureInfo(defaultLocale); - return true; - } - return false; - - } - - int length = 5; - CultureInfo culfureInfo = null; - if (context.OriginalUrl.Length >= 5) - { - if (!CultureInfoParser.TryParse(context.OriginalUrl.Substring(0, 5), out culfureInfo)) - { - CultureInfoParser.TryParse(context.OriginalUrl.Substring(0, 2), out culfureInfo); - length = 2; - } - } - else if (context.OriginalUrl.Length >= 2) - { - CultureInfoParser.TryParse(context.OriginalUrl.Substring(0, 2), out culfureInfo); - length = 2; - } - - if (culfureInfo != null) - { - context.Values["locale"] = culfureInfo; - context.RemainingUrl = context.OriginalUrl.Substring(length); - return true; - } - - if (!String.IsNullOrEmpty(defaultLocale)) - { - context.Values["locale"] = CultureInfo.GetCultureInfo(defaultLocale); - return true; - } - return false; - } - } -} \ No newline at end of file diff --git a/test/TestMvc4/Properties/AssemblyInfo.cs b/test/TestMvc4/Properties/AssemblyInfo.cs deleted file mode 100644 index c9cb5c60..00000000 --- a/test/TestMvc4/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +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("TestMvc4")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TestMvc4")] -[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("0a8b0883-ffec-48d4-8c09-117c7b7343bb")] - -// 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 Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test/TestMvc4/TestMvc4.csproj b/test/TestMvc4/TestMvc4.csproj deleted file mode 100644 index 5e3be1e9..00000000 --- a/test/TestMvc4/TestMvc4.csproj +++ /dev/null @@ -1,193 +0,0 @@ - - - - - Debug - AnyCPU - - - 2.0 - {662F383E-7768-4A06-A8B9-DA15A73E4D47} - {E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - TestMvc4 - TestMvc4 - v4.5 - false - true - - - - - ..\ - true - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - - ..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - - - - - - - - - - - - - True - ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - - - - ..\packages\Microsoft.AspNet.WebApi.Client.4.0.20710.0\lib\net40\System.Net.Http.Formatting.dll - - - - - True - ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll - - - ..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll - - - ..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.20710.0\lib\net40\System.Web.Http.WebHost.dll - - - True - ..\packages\Microsoft.AspNet.Razor.2.0.20715.0\lib\net40\System.Web.Razor.dll - - - True - ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll - - - True - ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll - - - True - ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll - - - - - - - - Global.asax - - - - - - - - - - - - Web.config - - - Web.config - - - - - - - - - - - - {c7a28a56-c534-4f93-a62c-0bb2d290bba0} - Neptuo.Bootstrap - - - {70114d0d-b9f1-464f-a068-9840d7fa6798} - Neptuo.Migrations - - - {45c70782-7b22-4cda-b8e4-9e71182e3a32} - Neptuo.Web.Routing - - - {e77c5a49-e807-4465-8cb1-18f9e3f5934c} - Neptuo.Xml - - - {2392ed97-e671-4871-81a4-c85975f33794} - Neptuo - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - - - - - True - True - 0 - / - http://localhost:57355/ - False - False - - - False - - - - - - - \ No newline at end of file diff --git a/test/TestMvc4/Views/Web.config b/test/TestMvc4/Views/Web.config deleted file mode 100644 index f179ab88..00000000 --- a/test/TestMvc4/Views/Web.config +++ /dev/null @@ -1,58 +0,0 @@ - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/TestMvc4/Web.Debug.config b/test/TestMvc4/Web.Debug.config deleted file mode 100644 index a83c1d4a..00000000 --- a/test/TestMvc4/Web.Debug.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/test/TestMvc4/Web.Release.config b/test/TestMvc4/Web.Release.config deleted file mode 100644 index 658b48e1..00000000 --- a/test/TestMvc4/Web.Release.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/test/TestMvc4/Web.config b/test/TestMvc4/Web.config deleted file mode 100644 index 02f5ff71..00000000 --- a/test/TestMvc4/Web.config +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/TestMvc4/packages.config b/test/TestMvc4/packages.config deleted file mode 100644 index ac622e07..00000000 --- a/test/TestMvc4/packages.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file