public static void ApplyProjection(CustomAttribute attribute, CustomAttributeValueProjection projection)
{
if (projection == null)
return;
bool version_or_deprecated;
bool multiple;
switch (projection.Treatment) {
case CustomAttributeValueTreatment.AllowSingle:
version_or_deprecated = false;
multiple = false;
break;
case CustomAttributeValueTreatment.AllowMultiple:
version_or_deprecated = false;
multiple = true;
break;
case CustomAttributeValueTreatment.VersionAttribute:
case CustomAttributeValueTreatment.DeprecatedAttribute:
version_or_deprecated = true;
multiple = true;
break;
default:
throw new ArgumentException ();
}
var attribute_targets = (AttributeTargets) attribute.ConstructorArguments [0].Value;
if (version_or_deprecated)
attribute_targets |= AttributeTargets.Constructor | AttributeTargets.Property;
attribute.ConstructorArguments [0] = new CustomAttributeArgument (attribute.ConstructorArguments [0].Type, attribute_targets);
attribute.Properties.Add (new CustomAttributeNamedArgument ("AllowMultiple", new CustomAttributeArgument (attribute.Module.TypeSystem.Boolean, multiple)));
attribute.projection = projection;
}