예제 #1
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     MappingRegistrar.Register();
     Mapper.Initialize();
 }
예제 #2
0
 protected void Application_Start()
 {
     System.Data.Entity.Database.SetInitializer(new LiteShopSeedData());
     GlobalConfiguration.Configure(WebApiConfig.Register);
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     MappingRegistrar.RegisterMappings();
     DependencyRegistrar.RegisterDependencies();
 }
예제 #3
0
        public void TestRegisterModelMappings()
        {
            //Arrange
            MappingRegistrar registrar = new MappingRegistrar();

            MapperConfiguration config = new MapperConfiguration(cfg =>
            {
                registrar.RegisterMappings(cfg);
            });

            // Act
            IMapper mapper = config.CreateMapper();

            // Assert
            mapper.ConfigurationProvider.AssertConfigurationIsValid();
        }
예제 #4
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            _container = new WindsorContainer();
            ComponentRegistrar.AddExcelComponentsTo(_container);
            RegisterBusiness();
            MappingRegistrar.AddMapping();

            _productModule = _container.Resolve <IProductModule>();

            Globals.Ribbons.RiaRibbon.btnSync.Click       += btnSync_Click;
            Globals.Ribbons.RiaRibbon.btnSaveUpdate.Click += btnSaveUpdate_Click;
            Globals.Ribbons.RiaRibbon.btnImage.Click      += btnImage_Click;

            RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();

            item.Label = "Test";
            Globals.Ribbons.RiaRibbon.ddlMainView.Items.Add(item);
        }
 public ClientController()
 {
     Mapper = MappingRegistrar.CreareMapper();
 }
예제 #6
0
 public void InitializeMappings()
 {
     MappingRegistrar.AddMapping();
 }
예제 #7
0
 protected virtual void InitializeAutoMapper()
 {
     MappingRegistrar.AddMapping();
 }
예제 #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            var now = DateTime.UtcNow;

            Serilog.Log.Logger = new LoggerConfiguration()
                                 .MinimumLevel.Information()
                                 .Enrich.FromLogContext()
                                 .WriteTo.Seq(Configuration["SeqServer"])
                                 .CreateLogger();

            var connectionString = Configuration["ConnString"];

            //EF
            services.AddScoped(typeof(IDatabaseFactory <LedgerLocalDbContext>), _ => new LedgerLocalDbFullDomainDatabaseFactory(connectionString));

            services.AddScoped(typeof(ILedgerLocalDbFullDomainRepository <>), typeof(LedgerLocalDbFullDomainRepositoryBase <>));

            services.AddScoped(typeof(ILedgerLocalDbFullDomainUnitOfWork), typeof(LedgerLocalDbFullDomainUnitOfWorkBase));

            services.AddTransient(typeof(IDbContextService), typeof(DbContextService));

            var gConf = new GlobalConfig()
            {
                SeqServer = Configuration["SeqServer"],
                EsUrl     = ""
            };

            var tBot = new TelegramBotClient(Configuration["TelegramKey"]);

            var telegramClient = new TelegramClientFactory();

            telegramClient.AdminClient  = tBot;
            telegramClient.PublicClient = tBot;

            services.AddLogging();

            services.AddSingleton(typeof(IGlobalConfig), gConf);

            var gws1 = Configuration["GrapheneBlockWs"];
            var gws2 = Configuration["GrapheneWalletWs"];

            var gc1 = new GrapheneConfig(gws1, gws2);

            services.AddSingleton(typeof(IGrapheneConfig), _ => gc1);

            //Services
            var kafkaUrl = Configuration["Kafka"];

            services.AddSingleton(typeof(IKafkaConfigFactory), _ => new KafkaConfigFactory(kafkaUrl));

            services.AddSingleton(typeof(IKafkaProducerConsumerFactory), typeof(KafkaProducerConsumerFactory));
            services.AddSingleton(typeof(IKafkaFacade), typeof(KafkaFacade));

            services.AddTransient(typeof(ICommonMessageService), typeof(CommonMessageService));

            services.AddSingleton(typeof(MapperConfiguration), MappingRegistrar.CreateMapperConfig());

            //services.AddSingleton(typeof(IElasticClient), new ElasticClient(new Uri("http://octopus.appswiss.ch:9200")));

            services.AddTransient(typeof(IRdfStoreBusiness), typeof(RdfStoreBusiness));

            services.AddTransient(typeof(IRunningStatBusiness), typeof(RunningStatBusiness));

            services.AddTransient(typeof(IElasticBusiness), typeof(ElasticBusiness));

            services.AddTransient(typeof(IKafkaEventService), typeof(KafkaEventService));

            services.AddTransient(typeof(IBlockTradeService), typeof(BlockTradeService));

            services.AddSingleton(typeof(ITelegramBotClient), tBot);

            services.AddSingleton(typeof(ITelegramClientFactory), telegramClient);

            services.AddSingleton(typeof(IBotService), typeof(BotService));

            services.AddSingleton(typeof(IWebSocketClientFactory), typeof(WebSocketClientFactory));

            services.AddTransient(typeof(IAssetService), typeof(AssetService));

            services.AddTransient(typeof(IAccountService), typeof(AccountService));

            services.AddTransient(typeof(ILimitOrderService), typeof(LimitOrderService));

            services.AddTransient(typeof(IGenericCrudService <,>), typeof(GenericCrudService <,>));

            services.AddTransient(typeof(IParticipateBusinessService), typeof(ParticipateBusinessService));


            //Job
            services.AddTransient(typeof(DummyJob), typeof(DummyJob));

            services.AddTransient(typeof(StatPoolingJob), typeof(StatPoolingJob));

            services.AddTransient(typeof(TelegramAdminJob), typeof(TelegramAdminJob));

            services.AddTransient(typeof(KafkaListenerJob), typeof(KafkaListenerJob));

            services.AddTransient(typeof(AccountListenerJob), typeof(AccountListenerJob));


            // Add framework services.
            services.AddMvc()
            .AddJsonOptions(
                opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); });

            //call this in case you need aspnet-user-authtype/aspnet-user-identity
            //services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

            // ********************
            // Setup CORS
            // ********************
            var corsBuilder = new CorsPolicyBuilder();

            corsBuilder.AllowAnyHeader();
            corsBuilder.AllowAnyMethod();
            corsBuilder.AllowAnyOrigin(); // For anyone access.
            //corsBuilder.WithOrigins("http://localhost:56573"); // for a specific url. Don't add a forward slash on the end!
            corsBuilder.AllowCredentials();

            services.AddCors(options =>
            {
                options.AddPolicy("SiteCorsPolicy", corsBuilder.Build());
            });

            services.AddSwaggerGen();

            services.ConfigureSwaggerGen(options =>
            {
                options.SingleApiVersion(new Info
                {
                    Version     = "v1",
                    Title       = "Quartz.Web API",
                    Description = "Quartz.Web API"
                });

                options.DescribeAllEnumsAsStrings();

                //var comments = new XPathDocument($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml");
                //options.OperationFilter<XmlCommentsOperationFilter>(comments);
                //options.ModelFilter<XmlCommentsModelFilter>(comments);
            });

            var sp = ConfigureQuartz(services);

            ServiceLocatorSingleton.Instance.ServiceProvider = sp;
            ServiceLocatorSingleton.Instance.UtcStartDate    = DateTime.UtcNow;

            return(sp);
        }
예제 #9
0
 protected BaseService()
 {
     Mapper = MappingRegistrar.CreateMapperConfiguration().CreateMapper();
 }