当前位置: 首页>>代码示例>>C#>>正文


C# FieldDefinition.Resolve方法代码示例

本文整理汇总了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;
        }
开发者ID:gitter-badger,项目名称:Patchwork,代码行数:36,代码来源:CreateNew.cs

示例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;
 }
开发者ID:GregRos,项目名称:Patchwork,代码行数:11,代码来源:CreateNew.cs


注:本文中的Mono.Cecil.FieldDefinition.Resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。