本文整理汇总了C#中ITypeResolver.FromType方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeResolver.FromType方法的具体用法?C# ITypeResolver.FromType怎么用?C# ITypeResolver.FromType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeResolver
的用法示例。
在下文中一共展示了ITypeResolver.FromType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFromType
public TypeSpec CreateFromType(ITypeResolver typeResolver, Type type)
{
Type[] typeArgs;
if (!type.TryExtractTypeArguments(typeof(IDictionary<,>), out typeArgs))
return null;
var keyType = typeArgs[0];
var valueType = typeArgs[1];
return new DictionaryTypeSpec(typeResolver,
type,
() => typeResolver.FromType(keyType),
() => typeResolver.FromType(valueType));
}
示例2: CreateFromType
public TypeSpec CreateFromType(ITypeResolver typeResolver, Type type)
{
if (typeResolver == null)
throw new ArgumentNullException(nameof(typeResolver));
if (type == null)
throw new ArgumentNullException(nameof(type));
Type itemTypeLocal;
if (type == typeof(string) || !type.TryGetEnumerableElementType(out itemTypeLocal))
return null;
return new EnumerableTypeSpec(typeResolver, type,
CreateLazy(() => typeResolver.FromType(itemTypeLocal)));
}
示例3: CreateFromType
public TypeSpec CreateFromType(ITypeResolver typeResolver, Type type)
{
if (typeof(IClientResource).IsAssignableFrom(type) && type != typeof(IClientResource))
{
var interfaceType = GetResourceNonProxyInterfaceType(type);
if (interfaceType == type)
return new ClientType(interfaceType, typeResolver);
return typeResolver.FromType(interfaceType);
}
return null;
}