當前位置: 首頁>>代碼示例>>C#>>正文


C# CustomAttribute.Resolve方法代碼示例

本文整理匯總了C#中Mono.Cecil.CustomAttribute.Resolve方法的典型用法代碼示例。如果您正苦於以下問題:C# CustomAttribute.Resolve方法的具體用法?C# CustomAttribute.Resolve怎麽用?C# CustomAttribute.Resolve使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.CustomAttribute的用法示例。


在下文中一共展示了CustomAttribute.Resolve方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DomCecilAttribute

		/*CustomAttribute customAttribute;
		
		public CustomAttribute CustomAttribute {
			get {
				return customAttribute;
			}
		}*/
		
		public DomCecilAttribute (CustomAttribute customAttribute)
		{
			//this.customAttribute = customAttribute;
			base.AttributeType = DomCecilMethod.GetReturnType (customAttribute.Constructor);
			base.Name          = customAttribute.Constructor.DeclaringType.FullName;
			
			try {
				// This Resolve call is required to load enum parameter values.
				// Without this call, enum parameters are omited.
				customAttribute.Resolve ();
			} catch {
				// If the resolve operation fails, just continue. The enum parameters will
				// be omited, but there will be other parameters
			}
			
			foreach (object par in customAttribute.ConstructorParameters)
				AddPositionalArgument (new System.CodeDom.CodePrimitiveExpression (par));
			
			foreach (System.Collections.DictionaryEntry entry in customAttribute.Properties)
				AddNamedArgument ((string)entry.Key, new System.CodeDom.CodePrimitiveExpression (entry.Value));
			
			foreach (System.Collections.DictionaryEntry entry in customAttribute.Fields)
				AddNamedArgument ((string)entry.Key, new System.CodeDom.CodePrimitiveExpression (entry.Value));
		}
開發者ID:transformersprimeabcxyz,項目名稱:monodevelop-1,代碼行數:32,代碼來源:DomCecilAttribute.cs

示例2: WriteCustomAttribute

        private void WriteCustomAttribute(CustomAttribute custom)
        {
            custom.Resolve();
            WriteDot();
            WriteKeyword("custom");
            WriteSpace();
            WriteMethodReference(custom.Constructor, true);
            WriteSpace();
            Write("=");
            WriteLine();
            if (custom.HasConstructorArguments || custom.HasProperties || custom.HasFields)
            {
                WriteOpenBreckets();
                WriteLine();
                Indent();
                if (custom.HasConstructorArguments)
                {
                    WriteCustomAttributeConstructorArguments(custom.ConstructorArguments);
                }
                if (custom.HasProperties)
                {
                    WriteCustomAttributeProperties(custom);
                }
                if (custom.HasFields)
                {
                    WriteCustomAttributeFields(custom);
                }
                Outdent();
                WriteEndBreckets();
            }

            else
            {
                Byte[] blob = custom.GetBlob();
                Write("(");
                WriteLine();
                Indent();
                WriteByteArray(blob);
                WriteLine();
                Outdent();
                Write(")");
                WriteLine();
            }
        }
開發者ID:juancarlosbaezpozos,項目名稱:JustDecompileEngine,代碼行數:44,代碼來源:IntermediateLanguageAttributeWriter.cs

示例3: MarkCustomAttribute

        void MarkCustomAttribute(CustomAttribute ca)
        {
            MarkMethod (ca.Constructor);

            if (!ca.Resolved) {
                ca = ca.Clone ();
                ca.Resolve ();
            }

            if (!ca.Resolved)
                return;

            MarkCustomAttributeParameters (ca);

            TypeReference constructor_type = ca.Constructor.DeclaringType;
            TypeDefinition type = constructor_type.Resolve ();
            if (type == null)
                throw new ResolutionException (constructor_type);

            MarkCustomAttributeProperties (ca, type);
            MarkCustomAttributeFields (ca, type);
        }
開發者ID:tigerhu67,項目名稱:monobuildtools,代碼行數:22,代碼來源:MarkStep.cs

示例4: GetCustomAttributeUsedTypes

		private static ICollection<TypeReference> GetCustomAttributeUsedTypes(CustomAttribute attribute)
		{
			List<TypeReference> usedTypes = new List<TypeReference>();

			attribute.Resolve();

			usedTypes.AddRange(Utilities.GetTypeReferenceTypesDepedningOn(attribute.AttributeType));

			for (int argIndex = 0; argIndex < attribute.ConstructorArguments.Count; argIndex++)
			{
				usedTypes.AddRange(GetAttributeArgumentValueUsedTypes(attribute.ConstructorArguments[argIndex]));
			}

			if (attribute.HasConstructorArguments || attribute.HasFields || attribute.HasProperties)
			{

				if (attribute.HasProperties)
				{
					TypeDefinition attributeType = attribute.AttributeType.Resolve();
					usedTypes.AddRange(GetAttributeNamedArgsUsedTypes(attributeType, attribute.Properties, false));
				}
				if (attribute.HasFields)
				{
					TypeDefinition attributeType = attribute.AttributeType.Resolve();
					usedTypes.AddRange(GetAttributeNamedArgsUsedTypes(attributeType, attribute.Fields, true));
				}
			}

			return usedTypes;
		}
開發者ID:Feng2012,項目名稱:JustDecompileEngine,代碼行數:30,代碼來源:AttributesUtilities.cs

示例5: WriteAttribute

        protected void WriteAttribute(CustomAttribute attribute, bool skipNewLine = false)
        {
            if (attributesNotToShow.Contains(attribute.AttributeType.FullName))
            {
                return;
            }

            bool resolvingProblem = false;
            attribute.Resolve();
            genericWriter.WriteToken(OpeningBracket);

            resolvingProblem = WriteAttributeSignature(attribute, resolvingProblem);

            genericWriter.WriteToken(ClosingBracket);

            if (resolvingProblem)
            {
                genericWriter.Write("    ");
                string comment = genericWriter.Language.CommentLines(ASSEMBLYNOTRESOLVEDERROR);
                genericWriter.Write(comment.Remove(comment.Length - 2));
            }

            if (!skipNewLine)
            {
                genericWriter.WriteLine();
            }
        }
開發者ID:juancarlosbaezpozos,項目名稱:JustDecompileEngine,代碼行數:27,代碼來源:AttributeWriter.cs

示例6: WriteGlobalAttribute

        private void WriteGlobalAttribute(CustomAttribute attribute, string keyword)
        {
            if (attributesNotToShow.Contains(attribute.AttributeType.FullName))
            {
                return;
            }

            bool resolvingProblem = false;
            attribute.Resolve();
            genericWriter.WriteToken(OpeningBracket);

            genericWriter.WriteKeyword(keyword);
            genericWriter.Write(":");
			genericWriter.WriteSpace();

            resolvingProblem = WriteAttributeSignature(attribute, resolvingProblem);

            genericWriter.WriteToken(ClosingBracket);

            if (resolvingProblem)
            {
                genericWriter.Write("    ");
                string comment = genericWriter.Language.CommentLines(ASSEMBLYNOTRESOLVEDERROR);
                genericWriter.Write(comment.Remove(comment.Length - 2));
            }

            genericWriter.WriteLine();
        }
開發者ID:juancarlosbaezpozos,項目名稱:JustDecompileEngine,代碼行數:28,代碼來源:AttributeWriter.cs

示例7: GetDynamicPositioningFlags

        public static bool[] GetDynamicPositioningFlags(CustomAttribute dynamicAttribute)
        {
            dynamicAttribute.Resolve();

            if (!dynamicAttribute.IsResolved)
            {
                throw new Exception("Could not resolve DynamicAttribute");
            }

            if (dynamicAttribute.ConstructorArguments.Count == 0)
            {
                return new bool[] { true };
            }

            if (dynamicAttribute.ConstructorArguments[0].Type.FullName != "System.Boolean[]")
            {
                throw new Exception("Invalid argument type for DynamicAttribute");
            }

            CustomAttributeArgument[] booleanArray = (CustomAttributeArgument[])dynamicAttribute.ConstructorArguments[0].Value;
            bool[] positioningFlags = new bool[booleanArray.Length];

            for (int i = 0; i < booleanArray.Length; i++)
            {
                positioningFlags[i] = (bool)booleanArray[i].Value;
            }

            return positioningFlags;
        }
開發者ID:Feng2012,項目名稱:JustDecompileEngine,代碼行數:29,代碼來源:DynamicHelper.cs


注:本文中的Mono.Cecil.CustomAttribute.Resolve方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。