本文整理汇总了C#中Microsoft.Cci.GetResolvedField方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Cci.GetResolvedField方法的具体用法?C# Microsoft.Cci.GetResolvedField怎么用?C# Microsoft.Cci.GetResolvedField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Cci
的用法示例。
在下文中一共展示了Microsoft.Cci.GetResolvedField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveField
private FieldInfo ResolveField(Cci.IFieldReference fieldRef)
{
var fieldDef = fieldRef.GetResolvedField(_context);
if (fieldDef != null && IsLocal(fieldRef.GetContainingType(_context)))
{
return _fieldBuilders[fieldDef];
}
FieldInfo result;
if (_fieldRefs.TryGetValue(fieldRef, out result))
{
return result;
}
Type declaringType = ResolveType(fieldRef.GetContainingType(_context));
Cci.ISpecializedFieldReference specializedRef = fieldRef.AsSpecializedFieldReference;
if (specializedRef != null)
{
if (IsLocal(specializedRef.UnspecializedVersion.GetContainingType(_context)))
{
// declaring type is TypeBuilder or TypeBuilderInstantiation since it's defined in the module being built:
FieldBuilder fieldBuilder = _fieldBuilders[(Cci.IFieldDefinition)specializedRef.UnspecializedVersion.AsDefinition(_context)];
result = TypeBuilder.GetField(declaringType, fieldBuilder);
}
else
{
FieldInfo unspecializedDefinition = ResolveField(specializedRef.UnspecializedVersion);
result = new FieldRef(declaringType, fieldRef.Name, unspecializedDefinition.FieldType);
}
}
else
{
GenericContext genericContext;
if (declaringType.IsGenericTypeDefinition)
{
genericContext = new GenericContext(declaringType.GetGenericArguments(), Type.EmptyTypes);
}
else
{
genericContext = default(GenericContext);
}
// TODO: modifiers?
Type fieldType = ResolveType(fieldRef.GetType(_context), genericContext);
result = new FieldRef(declaringType, fieldRef.Name, fieldType);
}
_fieldRefs.Add(fieldRef, result);
return result;
}