Fixed combination of Display Templated Helpers.

Had to make adjustments to allow the project to build (things that were missed by git).  Also made some changes to ensure it builds in CoreCLR.
This commit is contained in:
N. Taylor Mullen 2014-04-06 16:04:24 -07:00
parent 671c7dd59e
commit c0d06f1fbc
3 changed files with 14 additions and 6 deletions

View File

@ -36,6 +36,11 @@ namespace Microsoft.AspNet.Mvc
}
#endif
public static Type BaseType([NotNull] this Type type)
{
return type.GetTypeInfo().BaseType;
}
public static Type ExtractGenericInterface([NotNull] this Type queryType, Type interfaceType)
{
Func<Type, bool> matchesInterface = t => t.IsGenericType() && t.GetGenericTypeDefinition() == interfaceType;
@ -59,6 +64,11 @@ namespace Microsoft.AspNet.Mvc
}
#endif
public static bool IsEnum([NotNull] this Type type)
{
return type.GetTypeInfo().IsEnum;
}
public static bool IsGenericType([NotNull] this Type type)
{
return type.GetTypeInfo().IsGenericType;

View File

@ -42,8 +42,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
IdAttributeDotReplacement = "_";
}
public IModelMetadataProvider MetadataProvider { get; private set; }
public string IdAttributeDotReplacement { get; set; }
public HttpContext HttpContext { get; private set; }

View File

@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
var fullViewName = modeViewPath + "/" + viewName;
// Forcing synchronous behavior so users don't have to await templates.
var viewEngineResult = _viewEngine.FindPartialView(_viewContext.ViewEngineContext, fullViewName).Result;
var viewEngineResult = _viewEngine.FindPartialView(_viewContext.ViewEngineContext, fullViewName);
if (viewEngineResult.Success)
{
using (var writer = new StringWriter(CultureInfo.InvariantCulture))
@ -105,7 +105,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
else if (!metadata.IsComplexType)
{
// IsEnum is false for the Enum class itself
if (fieldType.IsEnum)
if (fieldType.IsEnum())
{
// Same as fieldType.BaseType.Name in this case
yield return "Enum";
@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
yield return "String";
}
else if (fieldType.IsInterface)
else if (fieldType.IsInterface())
{
if (typeof(IEnumerable).IsAssignableFrom(fieldType))
{
@ -132,7 +132,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
while (true)
{
fieldType = fieldType.BaseType;
fieldType = fieldType.BaseType();
if (fieldType == null)
{
break;