Mono.Cecil.WindowsRuntimeProjections.ApplyProjection C# (CSharp) Method

ApplyProjection() public static method

public static ApplyProjection ( CustomAttribute attribute, CustomAttributeValueProjection projection ) : void
attribute CustomAttribute
projection CustomAttributeValueProjection
return void
        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;
        }

Same methods

WindowsRuntimeProjections::ApplyProjection ( FieldDefinition field, FieldDefinitionProjection projection ) : void
WindowsRuntimeProjections::ApplyProjection ( Mono.Cecil.MethodDefinition method, MethodDefinitionProjection projection ) : void
WindowsRuntimeProjections::ApplyProjection ( Mono.Cecil.TypeDefinition type, TypeDefinitionProjection projection ) : void
WindowsRuntimeProjections::ApplyProjection ( TypeReference type, TypeReferenceProjection projection ) : void