FeatureModel should use Type.IsInstanceOf rather than direct type equality.

This commit is contained in:
GrabYourPitchforks 2014-02-14 16:26:13 -08:00
parent a34826d90b
commit 69addcac86
2 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using System.Threading; using System.Threading;
using Microsoft.AspNet.FeatureModel.Implementation; using Microsoft.AspNet.FeatureModel.Implementation;
@ -42,11 +43,7 @@ namespace Microsoft.AspNet.FeatureModel
{ {
if (_featureByFeatureType.TryGetValue(actualType, out feature)) if (_featureByFeatureType.TryGetValue(actualType, out feature))
{ {
#if NET45
var isInstanceOfType = type.IsInstanceOfType(feature); var isInstanceOfType = type.IsInstanceOfType(feature);
#else
var isInstanceOfType = feature != null && type == feature.GetType();
#endif
if (isInstanceOfType) if (isInstanceOfType)
{ {
@ -54,6 +51,8 @@ namespace Microsoft.AspNet.FeatureModel
} }
#if NET45 #if NET45
return Converter.Convert(type, actualType, feature); return Converter.Convert(type, actualType, feature);
#else
return null;
#endif #endif
} }
} }

View File

@ -27,12 +27,12 @@ namespace Microsoft.AspNet.FeatureModel
public object GetInterface(Type type) public object GetInterface(Type type)
{ {
#if NET45
if (type.IsInstanceOfType(_instance)) if (type.IsInstanceOfType(_instance))
{ {
return _instance; return _instance;
} }
#if NET45
foreach (var interfaceType in _instance.GetType().GetInterfaces()) foreach (var interfaceType in _instance.GetType().GetInterfaces())
{ {
if (interfaceType.FullName == type.FullName) if (interfaceType.FullName == type.FullName)