public IEnumerable <AspectInstance> ProvideAspects(object targetElement)
    {
        IAspectRepositoryService repositoryService = PostSharpEnvironment.CurrentProject.GetService <IAspectRepositoryService>();

        if (!repositoryService.HasAspect(targetElement, typeof(FirstAspect)))
        {
            yield return(new AspectInstance(targetElement, new FirstAspect()));
        }
        if (!repositoryService.HasAspect(targetElement, typeof(SecondAspect)))
        {
            yield return(new AspectInstance(targetElement, new SecondAspect()));
        }
    }
Beispiel #2
0
    public IEnumerable <AspectInstance> ProvideAspects(object targetElement)
    {
        ParameterInfo            parameter = (ParameterInfo)targetElement;
        IAspectRepositoryService aspectRepositoryService = PostSharpEnvironment.CurrentProject.GetService <IAspectRepositoryService>();

        if (!aspectRepositoryService.HasAspect(parameter.Member, typeof(HTMLEncodeImplAspect)))
        {
            yield return(new AspectInstance(parameter.Member, new HTMLEncodeImplAspect()));
        }
    }
    public IEnumerable <AspectInstance> ProvideAspects(object targetElement)
    {
        Type type = ((MethodBase)targetElement).DeclaringType;
        IAspectRepositoryService repository = PostSharpEnvironment.CurrentProject.GetService <IAspectRepositoryService>();

        if (!repository.HasAspect(type, typeof(CursorPropertyTypeAttribute)))
        {
            yield return(new AspectInstance(type, new CursorPropertyTypeAttribute()));
        }
    }
Beispiel #4
0
    public IEnumerable <AspectInstance> ProvideAspects(object targetElement)
    {
        MethodBase targetMethod = (MethodBase)targetElement;
        IAspectRepositoryService aspectRepositoryService = PostSharpEnvironment.CurrentProject.GetService <IAspectRepositoryService>();
        TimingAspect             aspect = new TimingAspect();

        MethodUsageCodeReference[] usages = ReflectionSearch.GetDeclarationsUsedByMethod(targetMethod);
        foreach (MethodUsageCodeReference codeReference in usages.Where(u => u.UsedDeclaration.MemberType == MemberTypes.Method))
        {
            if (!aspectRepositoryService.HasAspect(codeReference.UsedDeclaration, typeof(TimingAspect)))
            {
                yield return(new AspectInstance(codeReference.UsedDeclaration, aspect));
            }
        }
    }
Beispiel #5
0
            private static bool HasWeakEventClientAspect(Type type)
            {
                // Check if the current type has the aspect.
                if (aspectRepositoryService.HasAspect(type, typeof(WeakEventClientAttribute)))
                {
                    return(true);
                }

                // Check if the base type has the aspect.
                if (type.BaseType != null)
                {
                    return(HasWeakEventClientAspect(type.BaseType.IsGenericType ? type.BaseType.GetGenericTypeDefinition() : type.BaseType));
                }

                return(false);
            }