本文整理汇总了C#中Mono.Cecil.FieldDefinition.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# FieldDefinition.Resolve方法的具体用法?C# FieldDefinition.Resolve怎么用?C# FieldDefinition.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.FieldDefinition
的用法示例。
在下文中一共展示了FieldDefinition.Resolve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNewField
/// <summary>
/// Creates a new field in the target assembly, for the specified type.
/// </summary>
/// <param name="targetDeclaringType">The target declaring type.</param>
/// <param name="yourField">Your field.</param>
/// <param name="attr">The action attribute.</param>
/// <exception cref="PatchDeclerationException">Thrown if this member collides with another member, and the error cannot be resolved.</exception>
/// <returns></returns>
private NewMemberStatus CreateNewField(TypeDefinition targetDeclaringType, FieldDefinition yourField,
NewMemberAttribute attr)
{
if (attr.IsImplicit) {
Log_implicitly_creating_member("field", yourField);
} else {
Log_creating_member("field", yourField);
}
var maybeDuplicate = targetDeclaringType.GetField(yourField.Name);
if (maybeDuplicate != null) {
Log_duplicate_member("field", yourField, maybeDuplicate);
if ((DebugOptions & DebugFlags.CreationOverwrites) != 0) {
Log_overwriting();
return NewMemberStatus.Continue;
}
if (attr.IsImplicit) {
return NewMemberStatus.InvalidItem;
}
throw Errors.Duplicate_member("type", yourField.FullName, maybeDuplicate.FullName);
}
var targetField =
new FieldDefinition(yourField.Name, yourField.Resolve().Attributes, FixTypeReference(yourField.FieldType)) {
InitialValue = yourField.InitialValue, //probably for string consts
Constant = yourField.Constant
};
targetDeclaringType.Fields.Add(targetField);
return NewMemberStatus.Continue;
}
示例2: CopyField
private FieldDefinition CopyField(FieldDefinition yourField, string newName)
{
var targetField =
new FieldDefinition(newName, yourField.Resolve().Attributes, FixTypeReference(yourField.FieldType)) {
InitialValue = yourField.InitialValue, //for field RVA
Constant = yourField ,
MarshalInfo = CopyMarshalInfo(yourField.MarshalInfo),
HasConstant = yourField.HasConstant
};
return targetField;
}