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


C# FieldReference.Resolve方法代码示例

本文整理汇总了C#中Mono.Cecil.FieldReference.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# FieldReference.Resolve方法的具体用法?C# FieldReference.Resolve怎么用?C# FieldReference.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.FieldReference的用法示例。


在下文中一共展示了FieldReference.Resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WeakEventWeaver

 public WeakEventWeaver(FieldReference eventDelegate, ModuleImporter moduleimporter)
 {
     _eventDelegate = eventDelegate.Resolve();
     _moduleimporter = moduleimporter;
     _closedGenericEventHandler = moduleimporter.GetClosedEventHandlerT(eventDelegate.FieldType.GetEventArgsType());
     _isGenericHandler = _closedGenericEventHandler.FullName.Equals(eventDelegate.FieldType.FullName);
 }
开发者ID:adbancroft,项目名称:WeakEvents.Fody,代码行数:7,代码来源:WeakEventWeaver.cs

示例2: FixFieldReference

        private FieldReference FixFieldReference(FieldReference yourFieldRef)
        {
            if (yourFieldRef == null) {
                Log_called_to_fix_null("field");
                return null;
            }
            Log_fixing_reference("field", yourFieldRef);
            Asserts.AssertTrue(yourFieldRef.DeclaringType != null);

            var yourFieldDef = yourFieldRef.Resolve();
            if (yourFieldDef.IsDisablePatching()) {
                Log_trying_to_fix_disabled_reference("field", yourFieldRef);
            }
            var targetType = FixTypeReference(yourFieldRef.DeclaringType);
            var targetBaseFieldDef = yourFieldRef;
            if (yourFieldDef.Module.Assembly.IsPatchingAssembly()) {
                //additional checking
                var targetFieldDef = CurrentMemberCache.Fields.TryGet(yourFieldDef)?.TargetMember;
                if (targetFieldDef == null) {
                    throw Errors.Could_not_resolve_reference("field", yourFieldRef);
                }
                targetBaseFieldDef = targetFieldDef;
            } else {
                //we assume that types that aren't in a patching assembly will never reference types in a patching assembly
                targetBaseFieldDef = yourFieldRef;
            }
            var newFieldRef = targetBaseFieldDef.CloneReference();
            newFieldRef.DeclaringType = targetType;
            newFieldRef.FieldType = FixTypeReference(newFieldRef.FieldType);
            var targetFieldRef = TargetAssembly.MainModule.Import(newFieldRef);

            Log_fixed_reference("field", yourFieldRef, targetFieldRef);
            targetFieldRef.Module.Assembly.AssertEqual(TargetAssembly);

            return targetFieldRef;
        }
开发者ID:GregRos,项目名称:Patchwork,代码行数:36,代码来源:FixReferences.cs

示例3: CheckAndSaveStateField

 private bool CheckAndSaveStateField(FieldReference foundStateField)
 {
     FieldDefinition foundFieldDef = foundStateField.Resolve();
     if (stateField == null)
     {
         stateField = foundFieldDef;
     }
     else if(stateField != foundFieldDef)
     {
         return false;
     }
     return true;
 }
开发者ID:saravanaram,项目名称:JustDecompileEngine,代码行数:13,代码来源:StateMachineDisposeAnalyzer.cs

示例4: CreateWellName

 private static void CreateWellName(FieldReference fr)
 {
     var name = CleanName(fr.Name);
     var start = name.IndexOf(NONWELLFLAG);
     if (start == -1)
     {
         if (IsNameRepeated(fr.DeclaringType, name)) name = "f_" + name + "_" + GetShortName(fr.FieldType);
     }
     else
     {
         var fd = fr.Resolve();
         if (fd.DeclaringType.IsEnum)
         {
             var value = fd.Constant.ToString().Replace('-', 'n');
             var suffix = "_" + value;
             name = Replace(name, start, 1, "V") + suffix;
         }
         else
         {
             var suffix = "_" + GetShortName(fd.FieldType);
             name = fd.IsLiteral
                 ? Replace(name, start, 1, "CONST").ToUpper() + suffix.ToUpper() + "_" + Regex.Replace(fd.Constant.ToString(), @"\W", "_")
                 : Replace(name, start, 1, "f") + suffix;
         }
     }
     fr.mWellName = Regex.Replace(name, @"\W", "_");
 }
开发者ID:DKeeper1523,项目名称:ilspy_yh,代码行数:27,代码来源:YuehanNaming.cs

示例5: IsBlacklisted

        private bool IsBlacklisted(FieldReference field)
        {
            var fieldDef = field.Resolve();
            if (fieldDef == null)
                return true; // TODO: log

            if (ReferenceEquals(Module, fieldDef.Module))
                return false;

            return _accessLists.IsBlacklisted(fieldDef);
        }
开发者ID:Rohansi,项目名称:Sandbox.Fody,代码行数:11,代码来源:SandboxTypeMap.cs

示例6: GetFieldName

        protected virtual string GetFieldName(FieldReference field)
        {
            FieldDefinition fieldDefinition = field.Resolve();

            if (fieldDefinition != null && fieldDefinition.Module.FilePath == this.ModuleContext.Module.FilePath)
            {

                if (this.TypeContext != null && this.TypeContext.BackingFieldToNameMap.ContainsKey(fieldDefinition))
                {
                    return this.TypeContext.BackingFieldToNameMap[fieldDefinition];
                }

                return this.ModuleContext.RenamedMembersMap[fieldDefinition.MetadataToken.ToUInt32()];
            }

            return Utilities.EscapeName(GenericHelper.GetNonGenericName(field.Name), this.Language);
        }
开发者ID:saravanaram,项目名称:JustDecompileEngine,代码行数:17,代码来源:BaseLanguageWriter.cs

示例7: GetFieldReferenceId

 private UInt16 GetFieldReferenceId(
     FieldReference fieldReference)
 {
     UInt16 referenceId;
     if (_context.FieldReferencesTable.TryGetFieldReferenceId(fieldReference, out referenceId))
     {
         referenceId |= 0x8000; // External field reference
     }
     else
     {
         _context.FieldsTable.TryGetFieldReferenceId(fieldReference.Resolve(), false, out referenceId);
     }
     return referenceId;
 }
开发者ID:Roddoric,项目名称:Monkey.Robotics,代码行数:14,代码来源:CodeWriter.cs

示例8: GetFieldDefinition

		static FieldDefinition GetFieldDefinition(FieldReference field)
		{
			if (field != null && field.DeclaringType.IsGenericInstance)
				return field.Resolve();
			else
				return field as FieldDefinition;
		}
开发者ID:hlesesne,项目名称:ILSpy,代码行数:7,代码来源:YieldReturnDecompiler.cs

示例9: AddField

        private void AddField(FieldReference field) {
            if (field == null || IsIgnored(field)) {
                return;
            }

            AddType(field.FieldType);
            AddType(field.DeclaringType);
            FieldDefinition resolvedField = field.Resolve();

            fields.Add(resolvedField);
        }
开发者ID:Don191,项目名称:JSIL,代码行数:11,代码来源:DeadCodeInfoProvider.cs

示例10: CheckAndSaveCurrentItemField

        private bool CheckAndSaveCurrentItemField(FieldReference foundCurrentItemFieldRef)
        {
            FieldDefinition fieldDef = foundCurrentItemFieldRef.Resolve();
            if(currentItemField == null)
            {
                currentItemField = fieldDef;
            }
            else if(currentItemField != fieldDef)
            {
                return false;
            }

            return true;
        }
开发者ID:is00hcw,项目名称:JustDecompileEngine,代码行数:14,代码来源:YieldStateMachineControlFlowRebuilder.cs

示例11: IsObsolete

        static bool IsObsolete(FieldReference field)
        {
            if (field == null)
                return false;

            bool obsolete = false;
            if (!fields.TryGetValue (field, out obsolete)) {
                FieldDefinition fd = field.Resolve ();
                obsolete = fd.HasAttribute ("System", "ObsoleteAttribute");
                fields.Add (field, obsolete);
            }
            return obsolete;
        }
开发者ID:alfredodev,项目名称:mono-tools,代码行数:13,代码来源:RemoveDependenceOnObsoleteCodeRule.cs

示例12: GenericFieldComparer

 static bool GenericFieldComparer(FieldReference fieldReference, FieldDefinition fieldDefinition)
 {
     return fieldDefinition == fieldReference.Resolve();
 }
开发者ID:Z731,项目名称:NotifyPropertyWeaver,代码行数:4,代码来源:IlGeneratedByDependencyReader.cs

示例13: FindLinked

        public virtual FieldReference FindLinked(FieldReference field)
        {
            FieldDefinition def = field.Resolve();
            if (def == null || !def.HasCustomAttributes) {
                return field;
            }
            CustomAttribute attrib = null;
            foreach (CustomAttribute attrib_ in def.CustomAttributes) {
                if (attrib_.AttributeType.FullName == "MonoMod.MonoModLinkTo") {
                    attrib = attrib_;
                    break;
                }
            }
            if (attrib == null) {
                return field;
            }

            TypeDefinition type = null;

            if (attrib.ConstructorArguments[0].Type.FullName == "System.String") {
                //TODO get type from name
            } else {
                type = FindType((TypeReference) attrib.ConstructorArguments[0].Value).Resolve();
            }

            //TODO get method from name
            for (int i = 0; i < type.Fields.Count; i++) {
                if (type.Methods[i].Name == ((string) attrib.ConstructorArguments[1].Value)) {
                    //Probably check for more than that
                    field = type.Fields[i];
                    break;
                }
            }

            //TODO cache somewhere

            return field;
        }
开发者ID:alikaptanoglu,项目名称:MonoMod,代码行数:38,代码来源:MonoMod.cs

示例14: IsAutoPropertyConstructorInitializerExpression

        private bool IsAutoPropertyConstructorInitializerExpression(FieldReference fieldReference, out PropertyDefinition property)
        {
            FieldDefinition fieldDefinition = fieldReference.Resolve();
            if (fieldDefinition != null)
            {
                Dictionary<FieldDefinition, PropertyDefinition> map = this.typeContext.FieldToPropertyMap;
                if (map.ContainsKey(fieldDefinition) &&
                    map[fieldDefinition] != null &&
                    !map[fieldDefinition].ShouldStaySplit())
                {
                    property = map[fieldDefinition];
                    return true;
                }
            }

            property = null;
            return false;
        }
开发者ID:saravanaram,项目名称:JustDecompileEngine,代码行数:18,代码来源:PropertyRecognizer.cs

示例15: IsVisibleFrom

		bool IsVisibleFrom (TypeDefinition type, FieldReference reference)
		{
			if (reference == null)
				return true;

			FieldDefinition field = reference.Resolve ();
			if (field == null)
				return true;

			TypeDefinition dec = (TypeDefinition) field.DeclaringType;
			if (!IsVisibleFrom (type, dec))
				return false;

			if (field.IsPublic)
				return true;

			if (type == dec || IsNestedIn (type, dec))
				return true;

			if (field.IsFamily && InHierarchy (type, dec))
				return true;

			if (field.IsFamilyOrAssembly && (!AreInDifferentAssemblies (type, dec) || InHierarchy (type, dec)))
				return true;

			if (field.IsFamilyAndAssembly && (!AreInDifferentAssemblies (type, dec) && InHierarchy (type, dec)))
				return true;

			if (!AreInDifferentAssemblies (type, dec) && field.IsAssembly)
				return true;

			return false;
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:33,代码来源:CheckVisibility.cs


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