protected CustomAttribute BuildCustomAttribute(MethodReference ctor, CustomAttrib sig) { CustomAttribute cattr = new CustomAttribute(ctor); foreach (CustomAttrib.FixedArg fa in sig.FixedArgs) { cattr.ConstructorParameters.Add(GetFixedArgValue(fa)); } foreach (CustomAttrib.NamedArg na in sig.NamedArgs) { object value = GetFixedArgValue(na.FixedArg); if (na.Field) { cattr.Fields [na.FieldOrPropName] = value; cattr.SetFieldType(na.FieldOrPropName, GetFixedArgType(na.FixedArg)); } else if (na.Property) { cattr.Properties [na.FieldOrPropName] = value; cattr.SetPropertyType(na.FieldOrPropName, GetFixedArgType(na.FixedArg)); } else { throw new ReflectionException("Non valid named arg"); } } return(cattr); }
protected CustomAttribute BuildCustomAttribute(MethodReference ctor, CustomAttrib sig) { CustomAttribute cattr = new CustomAttribute (ctor); foreach (CustomAttrib.FixedArg fa in sig.FixedArgs) cattr.ConstructorParameters.Add (GetFixedArgValue (fa)); foreach (CustomAttrib.NamedArg na in sig.NamedArgs) { object value = GetFixedArgValue (na.FixedArg); if (na.Field) { cattr.Fields [na.FieldOrPropName] = value; cattr.SetFieldType (na.FieldOrPropName, GetNamedArgType (na)); } else if (na.Property) { cattr.Properties [na.FieldOrPropName] = value; cattr.SetPropertyType (na.FieldOrPropName, GetNamedArgType (na)); } else throw new ReflectionException ("Non valid named arg"); } return cattr; }
public override void VisitCustomAttribute (CustomAttribute customAttr) { customAttr.Constructor = GetMethodReference (customAttr.Constructor); Hashtable dict = new Hashtable (customAttr.Fields); foreach (DictionaryEntry entry in dict) customAttr.SetFieldType ( (string) entry.Key, GetTypeReference (customAttr.GetFieldType ((string) entry.Key))); dict = new Hashtable (customAttr.Properties); foreach (DictionaryEntry entry in dict) customAttr.SetPropertyType ( (string) entry.Key, GetTypeReference (customAttr.GetPropertyType ((string) entry.Key))); }