Autofac 2.4.5.724 API change for ReflectionExtensions IsClosingTypeOf
Does IsClosingTypeOf still exist? What is the equivalent method in TypeExtensions?
I guess I'll have to bite the bullet and install hg and download the code. I've been trying to avoid doing this for sometime now... I'm just very busy right now with deadlines ;)
Update This is the code from branch 2.3
public static bool IsClosingTypeOf(this Type type, Type openGenericTyp开发者_如何学运维e)
{
Enforce.ArgumentNotNull(type, "type");
Enforce.ArgumentNotNull(openGenericType, "openGenericType");
return type.IsGenericType && type.GetGenericTypeDefinition() == openGenericType;
}
It's not the same as IsClosedTypeOf
I tried substituting the IsClosedTypeOf for IsClosingTypeOf but with no luck, my tests broke.
Are you looking for IsClosedTypeOf
in type Autofac.TypeExtensions
? It's defined in trunk as
/// <summary>Determines whether the candidate type supports any base or
/// interface that closes the provided generic type.</summary>
/// <param name="this"></param>
/// <param name="openGeneric"></param>
/// <returns></returns>
public static bool IsClosedTypeOf(this Type @this, Type openGeneric)
{
if (@this == null) throw new ArgumentNullException("this");
if (openGeneric == null) throw new ArgumentNullException("openGeneric");
if (!(openGeneric.IsGenericTypeDefinition || openGeneric.ContainsGenericParameters))
throw new ArgumentException(string.Format(TypeExtensionsResources.NotOpenGenericType, openGeneric.FullName));
return @this.GetTypesThatClose(openGeneric).Any();
}
精彩评论