public static void AddIfNotExists(CustomAttributeCollection customAttributes) { if (!IsDefined(customAttributes)) { Build(customAttributes.Add()); } }
public void InjectAttributeOn(ICustomAttributeProvider provider, string attributeType) { //Info("{1}: {0}", provider, attributeType); CustomAttributeCollection attributes = provider.CustomAttributes; attributes.Add(new CustomAttribute(DefaultConstructorReferenceFor(attributeType))); }
void AddSecurityAttribute(ICustomAttributeProvider provider, AttributeType type) { if (HasSecurityAttribute(provider, type)) { return; } CustomAttributeCollection attributes = provider.CustomAttributes; switch (type) { case AttributeType.Critical: attributes.Add(CreateCriticalAttribute()); break; case AttributeType.SafeCritical: attributes.Add(CreateSafeCriticalAttribute()); break; } }