Mono.Cecil.CustomAttribute.Resolve C# (CSharp) Method

Resolve() private method

private Resolve ( ) : void
return void
        void Resolve()
        {
            if (resolved || !HasImage)
                return;

            Module.Read (this, (attribute, reader) => {
                try {
                    reader.ReadCustomAttributeSignature (attribute);
                    resolved = true;
                } catch (ResolutionException) {
                    if (arguments != null)
                        arguments.Clear ();
                    if (fields != null)
                        fields.Clear ();
                    if (properties != null)
                        properties.Clear ();

                    resolved = false;
                }
                return this;
            });
        }

Usage Example

		/*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));
		}
All Usage Examples Of Mono.Cecil.CustomAttribute::Resolve