Exemple #1
0
        public IEnumerable <AopTemplate> GetPropertyTemplates(PropertyDeclarationSyntax node)
        {
            ClassDeclarationSyntax     classDeclaration     = node.Ancestors().OfType <ClassDeclarationSyntax>().FirstOrDefault();
            NamespaceDeclarationSyntax namespaceDeclaration = classDeclaration.Ancestors().OfType <NamespaceDeclarationSyntax>().FirstOrDefault();

            var propertyTemplates = new List <AopTemplate>();

            var globalTemplate = _templateService.GetGlobalTemplates(_filePath, namespaceDeclaration?.Name?.ToString(), classDeclaration?.Identifier.ToString(), propertyName: node.Identifier.ToString());

            propertyTemplates.AddRange(globalTemplate.Where(w => w.Action == AopTemplateAction.All || w.Action == AopTemplateAction.Properties));

            AddTemplatesFromClass(propertyTemplates, AopTemplateAction.Properties, classDeclaration, node.Identifier.ToString(), node.Modifiers);
            AddTemplatesFromAttributes(propertyTemplates, AopTemplateAction.Properties, node.AttributeLists, AopTemplateAction.Properties);

            if (!String.IsNullOrEmpty(BuilderSettings.OnlyTemplate))
            {
                return(propertyTemplates.Where(w => w.TemplateName == BuilderSettings.OnlyTemplate));
            }

            return(propertyTemplates.OrderBy(o => o.AdvicePriority));
        }
Exemple #2
0
        public SyntaxNode[] VisitPropertyDeclaration(PropertyDeclarationSyntax node, AopTemplate template)
        {
            var result = new List <SyntaxNode>();

            ClassDeclarationSyntax classDeclaration = node.Ancestors().OfType <ClassDeclarationSyntax>().FirstOrDefault();

            string propertyName = node.Identifier.ToString();

            Console.Out.WriteLine("Property:  " + propertyName);

            if (BuilderSettings.Verbosity > 1)
            {
                Console.Out.WriteLine(node.ToFullString());
            }

            IEnumerable <SyntaxNode> resultNodes = ProcessTemplate(_templateService, template, node, classDeclaration);

            if (resultNodes != null)
            {
                result.AddRange(resultNodes);
            }

            return(result.Count > 0 ? result.ToArray() : null);
        }