Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 4
0
 /// <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;
 }