public IEnumerable <Advice> GetAdvices(Aspect aspect)
        {
            ArgumentUtility.CheckNotNull("aspect", aspect);

            foreach (var method in aspect.Type.GetMethods())
            {
                var adviceAttribute = method.GetCustomAttributes <AdviceAttribute> (true).SingleOrDefault();
                if (adviceAttribute == null)
                {
                    continue;
                }

                var execution = adviceAttribute.Execution;

                var attributePointcut = _pointcutBuilder.Build(method);
                var mappings          = _contextMappingBuilder.GetMappingsAndPointcut(method);
                var pointcut          = new AllPointcut(new[] { attributePointcut, mappings.Item2 });

                var orderings    = new List <IOrdering>();
                var crosscutting = new Crosscutting(pointcut, orderings, method.Name);
                orderings.AddRange(_orderingBuilder.BuildOrderings(crosscutting, method));

                yield return(new Advice(aspect, method, execution, crosscutting));
            }
        }
        private Aspect Build(Type type, IAspectInfo info, IAspectConstruction construction, IPointcut pointcut, int priority = 0)
        {
            var scope      = info.Scope;
            var activation = info.Activation;
            var role       = info.Role;
            var orderings  = new List <IOrdering>();

            var crosscutting = new Crosscutting(pointcut, orderings, priority, type, role);

            orderings.AddRange(_orderingBuilder.BuildOrderings(crosscutting, type));

            var advices       = new List <Advice>();
            var introductions = new List <MemberIntroduction>();
            var imports       = new List <MemberImport>();

            var aspect = new Aspect(type, scope, activation, construction, crosscutting, advices, imports, introductions);

            advices.AddRange(_adviceBuilder.GetAdvices(aspect));
            imports.AddRange(_interTypeBuilder.AddMemberImports(aspect));
            introductions.AddRange(_interTypeBuilder.AddMemberIntroductions(aspect));

            return(aspect);
        }
Exemple #3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
 public void ConfigureServices(IServiceCollection services)
 {
     Crosscutting.RegisterServices(services);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StationService"/> class.
 /// </summary>
 /// <param name="stationRepository">The station repository.</param>
 public StationService(Core.Repositories.IStationRepository stationRepository, Crosscutting.ILogger logger)
 {
     this._stationRepository = stationRepository;
     this._logger = logger;
 }