Ejemplo n.º 1
0
        protected virtual void ConfigureLogger(ConfigurationExpression config, ApiGatewaySettings settings)
        {
            var logger = BackgroundWorkerFactory.Logger ?? new Log4NetLogger(settings.LogPath, settings.LogFilename, settings.LogArchivePath);

            config.For <ILogger>().Use(logger);
            config.Policies.FillAllPropertiesOfType <ILogger>();
            BackgroundWorkerFactory.Logger = logger;
        }
Ejemplo n.º 2
0
        public CompositionRoot()
        {
            _settings  = new ApiGatewaySettings();
            _container = new Container(
                config =>
            {
                ConfigureLogger(config, _settings);
                ConfigureRest(config, _settings);
            }
                );

            _container.Inject(typeof(IDependencyResolver), new StructureMapDependencyResolver(_container));
        }
Ejemplo n.º 3
0
        public CompositionRoot()
        {
            _settings  = new ApiGatewaySettings();
            _container = new Container(
                config =>
            {
                ConfigureLogger(config, _settings);
                ConfigureRest(config, _settings);
                var sRoot = Edgar.Service.CompositionRoot.CompositeRootInstanace();
                config.For <IEdgarApi>().Use(sRoot.GetInstance <IEdgarApi>());
                config.For <IAiPortfolioSvc>().Use <AiPortfolioSvc>();
            }
                );

            _container.Inject(typeof(IDependencyResolver), new StructureMapDependencyResolver(_container));
        }
Ejemplo n.º 4
0
        private void ConfigureRest(ConfigurationExpression config, ApiGatewaySettings settings)
        {
            var httpConfig = config.ForConcreteType <HttpServiceOptions>().Configure
                             .Ctor <string>().Is(settings.Http.BaseUrl)
                             .Setter(m => m.PermissionedApplications).Is(settings.PermissionedApplications)
                             .Setter(m => m.DependencyResolver).IsTheDefault()
                             .Setter(m => m.DisableAuthorization).Is(settings.DisableAuthorization)
                             .Setter(m => m.DefaultTokenExpiry).Is(settings.Http.DefaultTokenExpiry)
                             .Setter(m => m.AllowTokenAsUrlParameter).Is(settings.Http.AllowTokenAsUrlParameter);

            config.For <IService>().Add <HttpService>()
            .Named(nameof(HttpService))
            .Ctor <HttpServiceOptions>().Is(httpConfig);

            config
            .ForConcreteType <ApiGatewayService>().Configure
            .Ctor <IService>("httpService").Is(ctx => ctx.GetInstance <IService>(nameof(HttpService)));

            //controllers
            config.ForConcreteType <Http.Controller.TestController>();
        }
Ejemplo n.º 5
0
        protected virtual void ConfigureAuthorization(ConfigurationExpression config, ApiGatewaySettings settings, TimeSpan permissionRefresh = default(TimeSpan))
        {
            config.For <IPermissionedEntityFilter>().Use <PermissionedEntityFilter>().Singleton();

            config
            .For <IPermissionService>()
            .Use <CachedPermissionService>()
            .Ctor <TimeSpan>().Is(permissionRefresh == default(TimeSpan) ? TimeSpan.FromMinutes(30) : permissionRefresh)
            .Ctor <IPermissionService>().Is <Infrastructure.Permissions.PermissionService>(cfg => cfg
                                                                                           .Ctor <Infrastructure.Wcf.PermissionService.PermissionService>().Is("service",
                                                                                                                                                               () => new PermissionServiceClient("TcpPermissionEndpoint")));

            if (settings.DisableAuthorization)
            {
                config.For <IPermissionedEntityFilter>()
                .Use <NoAuthPermissionedEntityFilter>()
                .Singleton();
            }
            else
            {
                config.For <IPermissionedEntityFilter>()
                .Use <PermissionedEntityFilter>()
                .Singleton();
            }
        }