Ejemplo n.º 1
0
        private void AddTemplatesFromClass(List <AopTemplate> templates, AopTemplateAction templateAction, ClassDeclarationSyntax classDeclaration, string currentName, SyntaxTokenList modifiers)
        {
            if (!_classTemplates.TryGetValue(classDeclaration.Identifier.ToString(), out List <AopTemplate> classTemplates))
            {
                return;
            }

            foreach (var classTemplate in classTemplates)
            {
                if (classTemplate.Action == AopTemplateAction.IgnoreAll)
                {
                    templates.Clear();
                }
                else if (classTemplate.Action == AopTemplateAction.Ignore)
                {
                    templates.RemoveTemplateByName(classTemplate.TemplateName);
                }
                else if (classTemplate.Action == AopTemplateAction.All || classTemplate.Action == templateAction)
                {
                    if (String.IsNullOrEmpty(classTemplate.NameFilter) || Regex.IsMatch(currentName, classTemplate.NameFilter, RegexOptions.IgnoreCase))
                    {
                        if (classTemplate.Modifier == AopTemplateModifier.All ||
                            (((classTemplate.Modifier & AopTemplateModifier.Public) > 0 || (classTemplate.Modifier == AopTemplateModifier.Default)) && modifiers.Any(w => w.Kind() == SyntaxKind.PublicKeyword)) ||
                            ((classTemplate.Modifier & AopTemplateModifier.Protected) > 0 && modifiers.Any(w => w.Kind() == SyntaxKind.ProtectedKeyword)) ||
                            ((classTemplate.Modifier & AopTemplateModifier.Private) > 0 && modifiers.Any(w => w.Kind() == SyntaxKind.PrivateKeyword)))
                        {
                            templates.UpdateTemplate(classTemplate);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public AopTemplate(string templateName,
                    int aspectPriority           = 0,
                    string extraTag              = null,
                    string nameFilter            = null,
                    AopTemplateAction action     = AopTemplateAction.Default,
                    AopTemplateModifier modifier = AopTemplateModifier.Default)
 {
     TemplateName   = templateName;
     AdvicePriority = aspectPriority;
     ExtraTag       = extraTag;
     Action         = action;
     Modifier       = modifier;
     NameFilter     = nameFilter;
 }
Ejemplo n.º 3
0
        public static void AddTemplatesFromAttributes(List <AopTemplate> templates, AopTemplateAction propertyAction, SyntaxList <AttributeListSyntax> attributeLists, AopTemplateAction defaultAs)
        {
            foreach (var template in Utils.GetAopTemplates(attributeLists))
            {
                if (template.Action == AopTemplateAction.Default)
                {
                    template.Action = defaultAs;
                }

                if (template.Action == AopTemplateAction.IgnoreAll)
                {
                    templates.Clear();
                }
                else if (template.Action == AopTemplateAction.Ignore)
                {
                    templates.RemoveTemplateByName(template.TemplateName);
                }
                else if (template.Action == AopTemplateAction.All || template.Action == propertyAction)
                {
                    templates.UpdateTemplate(template);
                }
            }
        }