本文整理汇总了C#中IRuntimeContext.ResolveTypeParameter方法的典型用法代码示例。如果您正苦于以下问题:C# IRuntimeContext.ResolveTypeParameter方法的具体用法?C# IRuntimeContext.ResolveTypeParameter怎么用?C# IRuntimeContext.ResolveTypeParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRuntimeContext
的用法示例。
在下文中一共展示了IRuntimeContext.ResolveTypeParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetScriptType
private JsExpression GetScriptType(IType type, TypeContext typeContext, IRuntimeContext context) {
if (type.Kind == TypeKind.Delegate) {
return CreateTypeReferenceExpression(KnownTypeReference.Delegate);
}
else if (type is ParameterizedType) {
var pt = (ParameterizedType)type;
var def = pt.GetDefinition();
var sem = _metadataImporter.GetTypeSemantics(def);
if (sem.Type == TypeScriptSemantics.ImplType.NormalType && !sem.IgnoreGenericArguments)
return JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(_systemScript), "makeGenericType"), CreateTypeReferenceExpression(type.GetDefinition()), JsExpression.ArrayLiteral(pt.TypeArguments.Select(a => GetScriptType(a, TypeContext.GenericArgument, context))));
else
return GetTypeDefinitionScriptType(type.GetDefinition(), typeContext);
}
else if (type.TypeParameterCount > 0) {
// This handles open generic types ( typeof(C<,>) )
return CreateTypeReferenceExpression(type.GetDefinition());
}
else if (type.Kind == TypeKind.Array) {
return CreateTypeReferenceExpression(KnownTypeReference.Array);
}
else if (type is ITypeParameter) {
return context.ResolveTypeParameter((ITypeParameter)type);
}
else if (type is ITypeDefinition) {
return GetTypeDefinitionScriptType((ITypeDefinition)type, typeContext);
}
else if (type.Kind == TypeKind.Anonymous || type.Kind == TypeKind.Null || type.Kind == TypeKind.Dynamic) {
return CreateTypeReferenceExpression(KnownTypeReference.Object);
}
else {
throw new InvalidOperationException("Could not determine the script type for " + type + ", context " + typeContext);
}
}