예제 #1
0
        public static ParameterSyntax CreateWithAttribute(string attributeTypeName, string parameterTypeName, string parameterName)
        {
            if (attributeTypeName == null)
            {
                throw new ArgumentNullException(nameof(attributeTypeName));
            }

            if (parameterTypeName == null)
            {
                throw new ArgumentNullException(nameof(parameterTypeName));
            }

            if (parameterName == null)
            {
                throw new ArgumentNullException(nameof(parameterName));
            }

            return(SyntaxFactory
                   .Parameter(SyntaxFactory.Identifier(parameterName))
                   .WithAttributeLists(
                       SyntaxFactory.SingletonList(
                           SyntaxFactory.AttributeList(
                               SyntaxFactory.SingletonSeparatedList(
                                   SyntaxAttributeFactory.Create(attributeTypeName)))))
                   .WithType(SyntaxFactory.IdentifierName(parameterTypeName)));
        }
예제 #2
0
        public static AttributeListSyntax Create(string attributeName)
        {
            if (attributeName == null)
            {
                throw new ArgumentNullException(nameof(attributeName));
            }

            return(SyntaxFactory.AttributeList(
                       SyntaxFactory.SingletonSeparatedList(
                           SyntaxAttributeFactory.Create(attributeName))));
        }
예제 #3
0
        public static AttributeListSyntax CreateWithOneItemWithOneArgumentWithNameEquals(string attributeName, string argumentName, string argumentValue)
        {
            if (attributeName == null)
            {
                throw new ArgumentNullException(nameof(attributeName));
            }

            return(SyntaxFactory.AttributeList(
                       SyntaxFactory.SingletonSeparatedList(
                           SyntaxAttributeFactory
                           .Create(attributeName)
                           .WithArgumentList(
                               SyntaxAttributeArgumentListFactory.CreateWithOneItemWithNameEquals(argumentName, argumentValue)))));
        }