From cc414e0fefcba60283dcc477861f0f0fcf3a15d3 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 30 Jan 2014 12:21:25 -0800 Subject: [PATCH] * Renaming Mvc.Forms to Mvc.Rendering * Moving data types to Mvc.ModelBinding --- WebFx.sln | 42 +++-- samples/MvcSample/project.json | 2 + src/Microsoft.AspNet.Mvc.Forms/CryptoUtil.cs | 56 ------ src/Microsoft.AspNet.Mvc.Forms/TypeHelpers.cs | 174 ------------------ .../IRouteData.cs | 0 .../RequestContext.cs | 0 .../ViewContext.cs | 0 .../ViewData.cs | 0 .../ViewDataOfTModel.cs | 0 .../project.json | 11 ++ .../Razor/RazorCompilationService.cs | 28 --- src/Microsoft.AspNet.Mvc.Razor/project.json | 3 +- .../Html/FormMethod.cs | 0 .../Html/HtmlHelper.cs | 0 .../Html/HtmlHelperOfT.cs | 0 .../Html/HtmlString.cs | 0 .../Html/InputType.cs | 0 .../Html/TagBuilder.cs | 0 .../Html/TagRenderMode.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../View/IView.cs | 0 .../View/IViewEngine.cs | 0 .../View/ViewEngineResult.cs | 0 .../project.json | 3 +- .../View/CompositeViewEngine.cs | 56 ------ .../{View => }/ViewResult.cs | 0 src/Microsoft.AspNet.Mvc/project.json | 4 +- 27 files changed, 48 insertions(+), 331 deletions(-) delete mode 100644 src/Microsoft.AspNet.Mvc.Forms/CryptoUtil.cs delete mode 100644 src/Microsoft.AspNet.Mvc.Forms/TypeHelpers.cs rename src/{Microsoft.AspNet.Mvc/Routing => Microsoft.AspNet.Mvc.ModelBinding}/IRouteData.cs (100%) rename src/{Microsoft.AspNet.Mvc => Microsoft.AspNet.Mvc.ModelBinding}/RequestContext.cs (100%) rename src/{Microsoft.AspNet.Mvc/View => Microsoft.AspNet.Mvc.ModelBinding}/ViewContext.cs (100%) rename src/{Microsoft.AspNet.Mvc/View => Microsoft.AspNet.Mvc.ModelBinding}/ViewData.cs (100%) rename src/{Microsoft.AspNet.Mvc/View => Microsoft.AspNet.Mvc.ModelBinding}/ViewDataOfTModel.cs (100%) create mode 100644 src/Microsoft.AspNet.Mvc.ModelBinding/project.json rename src/{Microsoft.AspNet.Mvc.Forms => Microsoft.AspNet.Mvc.Rendering}/Html/FormMethod.cs (100%) rename src/{Microsoft.AspNet.Mvc.Forms => Microsoft.AspNet.Mvc.Rendering}/Html/HtmlHelper.cs (100%) rename src/{Microsoft.AspNet.Mvc.Forms => Microsoft.AspNet.Mvc.Rendering}/Html/HtmlHelperOfT.cs (100%) rename src/{Microsoft.AspNet.Mvc.Forms => Microsoft.AspNet.Mvc.Rendering}/Html/HtmlString.cs (100%) rename src/{Microsoft.AspNet.Mvc.Forms => Microsoft.AspNet.Mvc.Rendering}/Html/InputType.cs (100%) rename src/{Microsoft.AspNet.Mvc.Forms => Microsoft.AspNet.Mvc.Rendering}/Html/TagBuilder.cs (100%) rename src/{Microsoft.AspNet.Mvc.Forms => Microsoft.AspNet.Mvc.Rendering}/Html/TagRenderMode.cs (100%) rename src/{Microsoft.AspNet.Mvc.Forms => Microsoft.AspNet.Mvc.Rendering}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Mvc => Microsoft.AspNet.Mvc.Rendering}/View/IView.cs (100%) rename src/{Microsoft.AspNet.Mvc => Microsoft.AspNet.Mvc.Rendering}/View/IViewEngine.cs (100%) rename src/{Microsoft.AspNet.Mvc => Microsoft.AspNet.Mvc.Rendering}/View/ViewEngineResult.cs (100%) rename src/{Microsoft.AspNet.Mvc.Forms => Microsoft.AspNet.Mvc.Rendering}/project.json (61%) delete mode 100644 src/Microsoft.AspNet.Mvc/View/CompositeViewEngine.cs rename src/Microsoft.AspNet.Mvc/{View => }/ViewResult.cs (100%) diff --git a/WebFx.sln b/WebFx.sln index 763d8c69c4..73ca7b31aa 100644 --- a/WebFx.sln +++ b/WebFx.sln @@ -11,10 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.net45" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.k10", "src\Microsoft.AspNet.Mvc\Microsoft.AspNet.Mvc.k10.csproj", "{BA88E212-5889-48DC-823F-A3A67DDEF123}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Forms.net45", "src\Microsoft.AspNet.Mvc.Forms\Microsoft.AspNet.Mvc.Forms.net45.csproj", "{28AA31B2-6504-432D-8599-1501FE0B100A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Forms.k10", "src\Microsoft.AspNet.Mvc.Forms\Microsoft.AspNet.Mvc.Forms.k10.csproj", "{24947215-86AB-4DD0-B94E-88B1EC4DC877}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Razor.net45", "src\Microsoft.AspNet.Mvc.Razor\Microsoft.AspNet.Mvc.Razor.net45.csproj", "{365CA5C6-037D-4E6E-AF05-F5FA42E024EB}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Razor.k10", "src\Microsoft.AspNet.Mvc.Razor\Microsoft.AspNet.Mvc.Razor.k10.csproj", "{0D2C8C3D-AFC3-4E1F-A6D8-9F690EE5E063}" @@ -27,6 +23,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Razor. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Razor.Host.k10", "src\Microsoft.AspNet.Mvc.Razor.Host\Microsoft.AspNet.Mvc.Razor.Host.k10.csproj", "{613579ED-7B96-4F5C-8DBF-D2C580257BE2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.ModelBinding.k10", "src\Microsoft.AspNet.Mvc.ModelBinding\Microsoft.AspNet.Mvc.ModelBinding.k10.csproj", "{24947215-86AB-4DD0-B94E-88B1EC4DC877}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.ModelBinding.net45", "src\Microsoft.AspNet.Mvc.ModelBinding\Microsoft.AspNet.Mvc.ModelBinding.net45.csproj", "{28AA31B2-6504-432D-8599-1501FE0B100A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Rendering.k10", "src\Microsoft.AspNet.Mvc.Rendering\Microsoft.AspNet.Mvc.Rendering.k10.csproj", "{DA65D56F-1C40-4D38-B1E0-BF9641A98C52}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Rendering.net45", "src\Microsoft.AspNet.Mvc.Rendering\Microsoft.AspNet.Mvc.Rendering.net45.csproj", "{236CDB04-8FDA-4152-9A5B-7F98C19C663A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,14 +45,6 @@ Global {BA88E212-5889-48DC-823F-A3A67DDEF123}.Debug|Any CPU.Build.0 = Debug|Any CPU {BA88E212-5889-48DC-823F-A3A67DDEF123}.Release|Any CPU.ActiveCfg = Release|Any CPU {BA88E212-5889-48DC-823F-A3A67DDEF123}.Release|Any CPU.Build.0 = Release|Any CPU - {28AA31B2-6504-432D-8599-1501FE0B100A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {28AA31B2-6504-432D-8599-1501FE0B100A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {28AA31B2-6504-432D-8599-1501FE0B100A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {28AA31B2-6504-432D-8599-1501FE0B100A}.Release|Any CPU.Build.0 = Release|Any CPU - {24947215-86AB-4DD0-B94E-88B1EC4DC877}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {24947215-86AB-4DD0-B94E-88B1EC4DC877}.Debug|Any CPU.Build.0 = Debug|Any CPU - {24947215-86AB-4DD0-B94E-88B1EC4DC877}.Release|Any CPU.ActiveCfg = Release|Any CPU - {24947215-86AB-4DD0-B94E-88B1EC4DC877}.Release|Any CPU.Build.0 = Release|Any CPU {365CA5C6-037D-4E6E-AF05-F5FA42E024EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {365CA5C6-037D-4E6E-AF05-F5FA42E024EB}.Debug|Any CPU.Build.0 = Debug|Any CPU {365CA5C6-037D-4E6E-AF05-F5FA42E024EB}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -73,6 +69,22 @@ Global {613579ED-7B96-4F5C-8DBF-D2C580257BE2}.Debug|Any CPU.Build.0 = Debug|Any CPU {613579ED-7B96-4F5C-8DBF-D2C580257BE2}.Release|Any CPU.ActiveCfg = Release|Any CPU {613579ED-7B96-4F5C-8DBF-D2C580257BE2}.Release|Any CPU.Build.0 = Release|Any CPU + {24947215-86AB-4DD0-B94E-88B1EC4DC877}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24947215-86AB-4DD0-B94E-88B1EC4DC877}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24947215-86AB-4DD0-B94E-88B1EC4DC877}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24947215-86AB-4DD0-B94E-88B1EC4DC877}.Release|Any CPU.Build.0 = Release|Any CPU + {28AA31B2-6504-432D-8599-1501FE0B100A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28AA31B2-6504-432D-8599-1501FE0B100A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28AA31B2-6504-432D-8599-1501FE0B100A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28AA31B2-6504-432D-8599-1501FE0B100A}.Release|Any CPU.Build.0 = Release|Any CPU + {DA65D56F-1C40-4D38-B1E0-BF9641A98C52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA65D56F-1C40-4D38-B1E0-BF9641A98C52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA65D56F-1C40-4D38-B1E0-BF9641A98C52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA65D56F-1C40-4D38-B1E0-BF9641A98C52}.Release|Any CPU.Build.0 = Release|Any CPU + {236CDB04-8FDA-4152-9A5B-7F98C19C663A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {236CDB04-8FDA-4152-9A5B-7F98C19C663A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {236CDB04-8FDA-4152-9A5B-7F98C19C663A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {236CDB04-8FDA-4152-9A5B-7F98C19C663A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -82,11 +94,13 @@ Global {A7D7CD66-A407-4144-8AB7-07F895F87137} = {DAAE4C74-D06F-4874-A166-33305D2643CE} {64BD92BA-F313-496C-ACE6-B9C4C10C420E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {BA88E212-5889-48DC-823F-A3A67DDEF123} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} - {28AA31B2-6504-432D-8599-1501FE0B100A} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} - {24947215-86AB-4DD0-B94E-88B1EC4DC877} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {365CA5C6-037D-4E6E-AF05-F5FA42E024EB} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {0D2C8C3D-AFC3-4E1F-A6D8-9F690EE5E063} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {A25566C9-97C7-4770-BBC1-9B815D3B1380} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {613579ED-7B96-4F5C-8DBF-D2C580257BE2} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} + {24947215-86AB-4DD0-B94E-88B1EC4DC877} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} + {28AA31B2-6504-432D-8599-1501FE0B100A} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} + {DA65D56F-1C40-4D38-B1E0-BF9641A98C52} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} + {236CDB04-8FDA-4152-9A5B-7F98C19C663A} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} EndGlobalSection EndGlobal diff --git a/samples/MvcSample/project.json b/samples/MvcSample/project.json index 2923551b4a..e4dd07e4a6 100644 --- a/samples/MvcSample/project.json +++ b/samples/MvcSample/project.json @@ -6,6 +6,8 @@ "Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*", "Microsoft.AspNet.Razor" : "0.1-alpha-*", "Microsoft.AspNet.Mvc" : "", + "Microsoft.AspNet.Mvc.ModelBinding" : "", + "Microsoft.AspNet.Mvc.Rendering" : "", "Microsoft.AspNet.Mvc.Razor" : "", "Microsoft.AspNet.Mvc.Razor.Host" : "" }, diff --git a/src/Microsoft.AspNet.Mvc.Forms/CryptoUtil.cs b/src/Microsoft.AspNet.Mvc.Forms/CryptoUtil.cs deleted file mode 100644 index 9619c0dc59..0000000000 --- a/src/Microsoft.AspNet.Mvc.Forms/CryptoUtil.cs +++ /dev/null @@ -1,56 +0,0 @@ -#if NET45 -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security.Cryptography; - -namespace Microsoft.AspNet.Mvc -{ - internal static class CryptoUtil - { - // This method is specially written to take the same amount of time - // regardless of where 'a' and 'b' differ. Please do not optimize it. - public static bool AreByteArraysEqual(byte[] a, byte[] b) - { - if (a == null || b == null || a.Length != b.Length) - { - return false; - } - - bool areEqual = true; - for (int i = 0; i < a.Length; i++) - { - areEqual &= (a[i] == b[i]); - } - return areEqual; - } - - // Computes a SHA256 hash over all of the input parameters. - // Each parameter is UTF8 encoded and preceded by a 7-bit encoded - // integer describing the encoded byte length of the string. - [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "MemoryStream is resilient to double-Dispose")] - public static byte[] ComputeSHA256(IList parameters) - { - using (MemoryStream ms = new MemoryStream()) - { - using (BinaryWriter bw = new BinaryWriter(ms)) - { - foreach (string parameter in parameters) - { - bw.Write(parameter); // also writes the length as a prefix; unambiguous - } - bw.Flush(); - - using (SHA256Cng sha256 = new SHA256Cng()) - { - byte[] retVal = sha256.ComputeHash(ms.GetBuffer(), 0, checked((int)ms.Length)); - return retVal; - } - } - } - } - } -} -#endif \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Forms/TypeHelpers.cs b/src/Microsoft.AspNet.Mvc.Forms/TypeHelpers.cs deleted file mode 100644 index 291cf2957a..0000000000 --- a/src/Microsoft.AspNet.Mvc.Forms/TypeHelpers.cs +++ /dev/null @@ -1,174 +0,0 @@ -#if NET45 -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.AspNet.Mvc -{ - internal delegate bool TryGetValueDelegate(object dictionary, string key, out object value); - - internal static class TypeHelpers - { - private static readonly Dictionary _tryGetValueDelegateCache = new Dictionary(); - private static readonly ReaderWriterLockSlim _tryGetValueDelegateCacheLock = new ReaderWriterLockSlim(); - - private static readonly MethodInfo _strongTryGetValueImplInfo = typeof(TypeHelpers).GetMethod("StrongTryGetValueImpl", BindingFlags.NonPublic | BindingFlags.Static); - - public static readonly Assembly MsCorLibAssembly = typeof(string).Assembly; - public static readonly Assembly MvcAssembly = null; //typeof(ControllerBase).Assembly; - - // method is used primarily for lighting up new .NET Framework features even if MVC targets the previous version - // thisParameter is the 'this' parameter if target method is instance method, should be null for static method - public static TDelegate CreateDelegate(Assembly assembly, string typeName, string methodName, object thisParameter) where TDelegate : class - { - // ensure target type exists - Type targetType = assembly.GetType(typeName, false /* throwOnError */); - if (targetType == null) - { - return null; - } - - return CreateDelegate(targetType, methodName, thisParameter); - } - - public static TDelegate CreateDelegate(Type targetType, string methodName, object thisParameter) where TDelegate : class - { - // ensure target method exists - ParameterInfo[] delegateParameters = typeof(TDelegate).GetMethod("Invoke").GetParameters(); - Type[] argumentTypes = Array.ConvertAll(delegateParameters, pInfo => pInfo.ParameterType); - MethodInfo targetMethod = targetType.GetMethod(methodName, argumentTypes); - if (targetMethod == null) - { - return null; - } - - TDelegate d = Delegate.CreateDelegate(typeof(TDelegate), thisParameter, targetMethod, false /* throwOnBindFailure */) as TDelegate; - return d; - } - - public static TryGetValueDelegate CreateTryGetValueDelegate(Type targetType) - { - TryGetValueDelegate result; - - _tryGetValueDelegateCacheLock.EnterReadLock(); - try - { - if (_tryGetValueDelegateCache.TryGetValue(targetType, out result)) - { - return result; - } - } - finally - { - _tryGetValueDelegateCacheLock.ExitReadLock(); - } - - Type dictionaryType = ExtractGenericInterface(targetType, typeof(IDictionary<,>)); - - // just wrap a call to the underlying IDictionary.TryGetValue() where string can be cast to TKey - if (dictionaryType != null) - { - Type[] typeArguments = dictionaryType.GetGenericArguments(); - Type keyType = typeArguments[0]; - Type returnType = typeArguments[1]; - - if (keyType.IsAssignableFrom(typeof(string))) - { - MethodInfo strongImplInfo = _strongTryGetValueImplInfo.MakeGenericMethod(keyType, returnType); - result = (TryGetValueDelegate)Delegate.CreateDelegate(typeof(TryGetValueDelegate), strongImplInfo); - } - } - - // wrap a call to the underlying IDictionary.Item() - if (result == null && typeof(IDictionary).IsAssignableFrom(targetType)) - { - result = TryGetValueFromNonGenericDictionary; - } - - _tryGetValueDelegateCacheLock.EnterWriteLock(); - try - { - _tryGetValueDelegateCache[targetType] = result; - } - finally - { - _tryGetValueDelegateCacheLock.ExitWriteLock(); - } - - return result; - } - - public static Type ExtractGenericInterface(Type queryType, Type interfaceType) - { - if (MatchesGenericType(queryType, interfaceType)) - { - return queryType; - } - Type[] queryTypeInterfaces = queryType.GetInterfaces(); - return MatchGenericTypeFirstOrDefault(queryTypeInterfaces, interfaceType); - } - - public static object GetDefaultValue(Type type) - { - return (TypeAllowsNullValue(type)) ? null : Activator.CreateInstance(type); - } - - public static bool IsCompatibleObject(object value) - { - return (value is T || (value == null && TypeAllowsNullValue(typeof(T)))); - } - - public static bool IsNullableValueType(Type type) - { - return Nullable.GetUnderlyingType(type) != null; - } - - private static bool MatchesGenericType(Type type, Type matchType) - { - return type.IsGenericType && type.GetGenericTypeDefinition() == matchType; - } - - private static Type MatchGenericTypeFirstOrDefault(Type[] types, Type matchType) - { - for (int i = 0; i < types.Length; i++) - { - Type type = types[i]; - if (MatchesGenericType(type, matchType)) - { - return type; - } - } - return null; - } - - private static bool StrongTryGetValueImpl(object dictionary, string key, out object value) - { - IDictionary strongDict = (IDictionary)dictionary; - - TValue strongValue; - bool retVal = strongDict.TryGetValue((TKey)(object)key, out strongValue); - value = strongValue; - return retVal; - } - - private static bool TryGetValueFromNonGenericDictionary(object dictionary, string key, out object value) - { - IDictionary weakDict = (IDictionary)dictionary; - - bool containsKey = weakDict.Contains(key); - value = (containsKey) ? weakDict[key] : null; - return containsKey; - } - - public static bool TypeAllowsNullValue(Type type) - { - return (!type.IsValueType || IsNullableValueType(type)); - } - } -} -#endif \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc/Routing/IRouteData.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/IRouteData.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc/Routing/IRouteData.cs rename to src/Microsoft.AspNet.Mvc.ModelBinding/IRouteData.cs diff --git a/src/Microsoft.AspNet.Mvc/RequestContext.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/RequestContext.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc/RequestContext.cs rename to src/Microsoft.AspNet.Mvc.ModelBinding/RequestContext.cs diff --git a/src/Microsoft.AspNet.Mvc/View/ViewContext.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/ViewContext.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc/View/ViewContext.cs rename to src/Microsoft.AspNet.Mvc.ModelBinding/ViewContext.cs diff --git a/src/Microsoft.AspNet.Mvc/View/ViewData.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/ViewData.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc/View/ViewData.cs rename to src/Microsoft.AspNet.Mvc.ModelBinding/ViewData.cs diff --git a/src/Microsoft.AspNet.Mvc/View/ViewDataOfTModel.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/ViewDataOfTModel.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc/View/ViewDataOfTModel.cs rename to src/Microsoft.AspNet.Mvc.ModelBinding/ViewDataOfTModel.cs diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/project.json b/src/Microsoft.AspNet.Mvc.ModelBinding/project.json new file mode 100644 index 0000000000..049faf293e --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/project.json @@ -0,0 +1,11 @@ +{ + "version" : "0.1-alpha-*", + "dependencies": { + "Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*", + "Microsoft.AspNet.Abstractions": "0.1-alpha-*" + }, + "configurations": { + "net45": { }, + "k10" : { } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs b/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs index 932e20933e..c5e434b92e 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs @@ -40,33 +40,5 @@ namespace Microsoft.AspNet.Mvc.Razor return await _baseCompilationService.Compile(results.GeneratedCode); } - - private static StringBuilder GenerateNamespace(IFileInfo file) - { - string virtualPath = file.PhysicalPath; - if (virtualPath.StartsWith("~/", StringComparison.Ordinal)) - { - virtualPath = virtualPath.Substring(2); - } - - var namespaceBuilder = new StringBuilder(virtualPath.Length); - - foreach (char c in Path.GetDirectoryName(virtualPath)) - { - if (c == Path.DirectorySeparatorChar) - { - namespaceBuilder.Append('.'); - } - else if (!Char.IsLetterOrDigit(c)) - { - namespaceBuilder.Append('_'); - } - else - { - namespaceBuilder.Append(c); - } - } - return namespaceBuilder; - } } } diff --git a/src/Microsoft.AspNet.Mvc.Razor/project.json b/src/Microsoft.AspNet.Mvc.Razor/project.json index ab7dd92e67..55b6945cf9 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/project.json +++ b/src/Microsoft.AspNet.Mvc.Razor/project.json @@ -6,7 +6,8 @@ "Microsoft.AspNet.DependencyInjection": "0.1-alpha-*", "Microsoft.AspNet.Razor": "0.1-alpha-*", "Microsoft.AspNet.Mvc" : "", - "Microsoft.AspNet.Mvc.Forms" : "", + "Microsoft.AspNet.Mvc.ModelBinding" : "", + "Microsoft.AspNet.Mvc.Rendering" : "", "Microsoft.AspNet.Mvc.Razor.Host" : "" }, "configurations": { diff --git a/src/Microsoft.AspNet.Mvc.Forms/Html/FormMethod.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/FormMethod.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc.Forms/Html/FormMethod.cs rename to src/Microsoft.AspNet.Mvc.Rendering/Html/FormMethod.cs diff --git a/src/Microsoft.AspNet.Mvc.Forms/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc.Forms/Html/HtmlHelper.cs rename to src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs diff --git a/src/Microsoft.AspNet.Mvc.Forms/Html/HtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelperOfT.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc.Forms/Html/HtmlHelperOfT.cs rename to src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelperOfT.cs diff --git a/src/Microsoft.AspNet.Mvc.Forms/Html/HtmlString.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlString.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc.Forms/Html/HtmlString.cs rename to src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlString.cs diff --git a/src/Microsoft.AspNet.Mvc.Forms/Html/InputType.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/InputType.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc.Forms/Html/InputType.cs rename to src/Microsoft.AspNet.Mvc.Rendering/Html/InputType.cs diff --git a/src/Microsoft.AspNet.Mvc.Forms/Html/TagBuilder.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/TagBuilder.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc.Forms/Html/TagBuilder.cs rename to src/Microsoft.AspNet.Mvc.Rendering/Html/TagBuilder.cs diff --git a/src/Microsoft.AspNet.Mvc.Forms/Html/TagRenderMode.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/TagRenderMode.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc.Forms/Html/TagRenderMode.cs rename to src/Microsoft.AspNet.Mvc.Rendering/Html/TagRenderMode.cs diff --git a/src/Microsoft.AspNet.Mvc.Forms/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Mvc.Rendering/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc.Forms/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNet.Mvc.Rendering/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Mvc/View/IView.cs b/src/Microsoft.AspNet.Mvc.Rendering/View/IView.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc/View/IView.cs rename to src/Microsoft.AspNet.Mvc.Rendering/View/IView.cs diff --git a/src/Microsoft.AspNet.Mvc/View/IViewEngine.cs b/src/Microsoft.AspNet.Mvc.Rendering/View/IViewEngine.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc/View/IViewEngine.cs rename to src/Microsoft.AspNet.Mvc.Rendering/View/IViewEngine.cs diff --git a/src/Microsoft.AspNet.Mvc/View/ViewEngineResult.cs b/src/Microsoft.AspNet.Mvc.Rendering/View/ViewEngineResult.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc/View/ViewEngineResult.cs rename to src/Microsoft.AspNet.Mvc.Rendering/View/ViewEngineResult.cs diff --git a/src/Microsoft.AspNet.Mvc.Forms/project.json b/src/Microsoft.AspNet.Mvc.Rendering/project.json similarity index 61% rename from src/Microsoft.AspNet.Mvc.Forms/project.json rename to src/Microsoft.AspNet.Mvc.Rendering/project.json index 6c48daf311..cf56795aed 100644 --- a/src/Microsoft.AspNet.Mvc.Forms/project.json +++ b/src/Microsoft.AspNet.Mvc.Rendering/project.json @@ -2,7 +2,8 @@ "version" : "0.1-alpha-*", "dependencies": { "Microsoft.AspNet.Abstractions": "0.1-alpha-*", - "Microsoft.AspNet.Mvc": "" + "Microsoft.AspNet.DependencyInjection": "0.1-alpha-*", + "Microsoft.AspNet.Mvc.ModelBinding": "" }, "configurations": { "net45": { }, diff --git a/src/Microsoft.AspNet.Mvc/View/CompositeViewEngine.cs b/src/Microsoft.AspNet.Mvc/View/CompositeViewEngine.cs deleted file mode 100644 index 685b727d78..0000000000 --- a/src/Microsoft.AspNet.Mvc/View/CompositeViewEngine.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.AspNet.Mvc.View -{ - public class CompositeViewEngine : IViewEngine - { - private readonly List _viewEngines; - - public CompositeViewEngine() - : this(Enumerable.Empty()) - { - } - - public CompositeViewEngine(IEnumerable viewEngines) - { - _viewEngines = viewEngines.ToList(); - } - - public void Insert(int index, IViewEngine viewEngine) - { - _viewEngines.Insert(index, viewEngine); - } - - public void Add(IViewEngine viewEngine) - { - _viewEngines.Add(viewEngine); - } - - public async Task FindView(RequestContext controllerContext, string viewName) - { - if (_viewEngines.Count == 0) - { - return ViewEngineResult.NotFound(Enumerable.Empty()); - } - - var searchedPaths = new HashSet(StringComparer.OrdinalIgnoreCase); - for (int i = 0; i < _viewEngines.Count; i++) - { - ViewEngineResult result = await _viewEngines[i].FindView(controllerContext, viewName); - if (result.Success) - { - return result; - } - foreach (string location in result.SearchedLocations) - { - searchedPaths.Add(location); - } - } - - return ViewEngineResult.NotFound(searchedPaths); - } - } -} diff --git a/src/Microsoft.AspNet.Mvc/View/ViewResult.cs b/src/Microsoft.AspNet.Mvc/ViewResult.cs similarity index 100% rename from src/Microsoft.AspNet.Mvc/View/ViewResult.cs rename to src/Microsoft.AspNet.Mvc/ViewResult.cs diff --git a/src/Microsoft.AspNet.Mvc/project.json b/src/Microsoft.AspNet.Mvc/project.json index a01d4967d6..608143d2bc 100644 --- a/src/Microsoft.AspNet.Mvc/project.json +++ b/src/Microsoft.AspNet.Mvc/project.json @@ -3,7 +3,9 @@ "dependencies": { "Newtonsoft.Json": "5.0.8", "Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*", - "Microsoft.AspNet.Abstractions": "0.1-alpha-*" + "Microsoft.AspNet.Abstractions": "0.1-alpha-*", + "Microsoft.AspNet.Mvc.ModelBinding": "", + "Microsoft.AspNet.Mvc.Rendering": "" }, "configurations": { "net45": { },