示例#1
0
        public static void AddAttribute([CanBeNull] IFieldDeclaration fieldDeclaration, IClrTypeName attributeTypeName,
                                        IPsiModule psiModule, CSharpElementFactory elementFactory)
        {
            if (fieldDeclaration == null)
            {
                return;
            }

            var typeElement = TypeFactory.CreateTypeByCLRName(attributeTypeName, psiModule).GetTypeElement();

            if (typeElement != null)
            {
                var attribute = elementFactory.CreateAttribute(typeElement);
                fieldDeclaration.AddAttributeAfter(attribute, null);
            }
        }
示例#2
0
        public static void AddAttributeToSingleDeclaration([CanBeNull] IFieldDeclaration fieldDeclaration,
                                                           IClrTypeName attributeTypeName, IPsiModule psiModule, CSharpElementFactory elementFactory)
        {
            if (fieldDeclaration == null)
            {
                return;
            }

            var existingAttribute = GetAttribute(fieldDeclaration, attributeTypeName);

            if (existingAttribute != null)
            {
                return;
            }

            var attribute = CreateAttribute(attributeTypeName, psiModule, elementFactory);

            if (attribute != null)
            {
                fieldDeclaration.AddAttributeAfter(attribute, null);
            }
        }
示例#3
0
 public IAttribute AddAttributeAfter(IAttribute attribute, IAttribute anchor)
 {
     return(_fieldDeclaration.AddAttributeAfter(attribute, anchor));
 }