本文整理汇总了C#中Mono.Cecil.GenericInstanceType.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# GenericInstanceType.Resolve方法的具体用法?C# GenericInstanceType.Resolve怎么用?C# GenericInstanceType.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.GenericInstanceType
的用法示例。
在下文中一共展示了GenericInstanceType.Resolve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InflateType
public static GenericInstanceType InflateType(GenericContext context, GenericInstanceType genericInstanceType)
{
return ConstructGenericType(context, genericInstanceType.Resolve(), genericInstanceType.GenericArguments);
}
示例2: NormalizeMethod
public static MethodReference NormalizeMethod(GenericInstanceType declaringType, MethodReference methodRef)
{
var typeDef = declaringType.Resolve();
var genericTypesByName = new Dictionary<string, TypeReference>();
for (int i = 0; i < declaringType.GenericArguments.Count; i++) {
var genericArgument = declaringType.GenericArguments[i];
var genericParameter = typeDef.GenericParameters[i];
genericTypesByName.Add(genericParameter.Name, genericArgument);
}
var returnType = methodRef.ReturnType;
if (returnType is GenericParameter) {
// try to resolve the type based on the context of the declaringType
returnType = genericTypesByName[returnType.Name];
}
var reference = new MethodReference(methodRef.Name, returnType);
reference.DeclaringType = methodRef.DeclaringType;
foreach (ParameterDefinition parameter in methodRef.Parameters) {
var parameterType = parameter.ParameterType;
var genericParameter = parameterType as GenericParameter;
if (genericParameter != null) {
TypeReference found;
if (genericTypesByName.TryGetValue(genericParameter.Name, out found)) {
parameterType = found;
}
}
reference.Parameters.Add(new ParameterDefinition(parameterType));
}
return reference;
}