* Renaming Mvc.Forms to Mvc.Rendering
* Moving data types to Mvc.ModelBinding
This commit is contained in:
parent
7963eaf5fa
commit
cc414e0fef
42
WebFx.sln
42
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
|
||||
|
|
|
|||
|
|
@ -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" : ""
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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<string> 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
|
||||
|
|
@ -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<Type, TryGetValueDelegate> _tryGetValueDelegateCache = new Dictionary<Type, TryGetValueDelegate>();
|
||||
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<TDelegate>(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<TDelegate>(targetType, methodName, thisParameter);
|
||||
}
|
||||
|
||||
public static TDelegate CreateDelegate<TDelegate>(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<TKey, TValue>.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<T>(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<TKey, TValue>(object dictionary, string key, out object value)
|
||||
{
|
||||
IDictionary<TKey, TValue> strongDict = (IDictionary<TKey, TValue>)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
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"version" : "0.1-alpha-*",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*",
|
||||
"Microsoft.AspNet.Abstractions": "0.1-alpha-*"
|
||||
},
|
||||
"configurations": {
|
||||
"net45": { },
|
||||
"k10" : { }
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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": { },
|
||||
|
|
@ -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<IViewEngine> _viewEngines;
|
||||
|
||||
public CompositeViewEngine()
|
||||
: this(Enumerable.Empty<IViewEngine>())
|
||||
{
|
||||
}
|
||||
|
||||
public CompositeViewEngine(IEnumerable<IViewEngine> 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<ViewEngineResult> FindView(RequestContext controllerContext, string viewName)
|
||||
{
|
||||
if (_viewEngines.Count == 0)
|
||||
{
|
||||
return ViewEngineResult.NotFound(Enumerable.Empty<string>());
|
||||
}
|
||||
|
||||
var searchedPaths = new HashSet<string>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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": { },
|
||||
|
|
|
|||
Loading…
Reference in New Issue