Exemplo n.º 1
0
        public void ConfigureServices(IAppBuilder app, System.Web.Http.HttpConfiguration config)
        {
            var cacheConfig = CacheManager.Core.ConfigurationBuilder.LoadConfiguration("ServicesCache");
            var builder     = new ContainerBuilder();

            builder
            .RegisterInstance(RabbitMQMessagingLogger.FromConfiguration())
            .SingleInstance();
            builder
            .RegisterInstance(CacheFactory.FromConfiguration <object>(cacheConfig))
            .SingleInstance();
            builder
            .RegisterInstance(CacheFactory.FromConfiguration <object>(CacheManager.Core.ConfigurationBuilder.LoadConfiguration("AppCache")))
            .Named <ICacheManager <object> >("AppCache")
            .SingleInstance();
            builder
            .RegisterInstance(CacheFactory.FromConfiguration <object>(CacheManager.Core.ConfigurationBuilder.LoadConfiguration("SessionStateStorage")))
            .Named <ICacheManager <object> >("SessionStateStorage")
            .SingleInstance();
            builder
            .Register(c => new DSS3_LogisticsPoolingForUrbanDistribution.Hubs.EventsHub())
            .As <zAppDev.DotNet.Framework.Hubs.IApplicationHub>().SingleInstance();
            var repoBuilder = new RepositoryBuilder();

            builder
            .Register(c => repoBuilder)
            .As <zAppDev.DotNet.Framework.Data.DAL.IRepositoryBuilder>().SingleInstance();
            builder
            .Register(c => new zAppDev.DotNet.Framework.Workflow.WorkflowManager(repoBuilder))
            .As <zAppDev.DotNet.Framework.Workflow.WorkflowManager>().SingleInstance();
            builder
            .Register(c =>
            {
                var scheduleManager = new zAppDev.DotNet.Framework.Workflow.ScheduleManager(repoBuilder);
                scheduleManager.SetSchedules(new List <zAppDev.DotNet.Framework.Workflow.WorkflowSchedule> {
                    new zAppDev.DotNet.Framework.Workflow.WorkflowSchedule {
                        Workflow       = "WorkflowSock",
                        Active         = true,
                        CronExpression = "* * * * *"
                    }
                });
                return(scheduleManager);
            })
            .As <zAppDev.DotNet.Framework.Workflow.ScheduleManager>().SingleInstance();
            builder
            .Register(c => new NHAuditTrailManager())
            .As <INHAuditTrailManager>().SingleInstance();
            builder
            .Register(c =>
            {
                return(new Security.Encryption.EncryptionManager());
            })
            .As <zAppDev.DotNet.Framework.Data.Encryption.Manager.EncryptionManagerBase>()
            .SingleInstance();
            builder
            .Register(c =>
            {
                PerformanceMonitorConfiguration monitorConfiguration = null;
                return(monitorConfiguration);
            })
            .SingleInstance();
            var container = builder.Build();
            var csl       = new AutofacServiceLocator(container);

            ServiceLocator.SetLocatorProvider(() => csl);
            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
        }
Exemplo n.º 2
0
        public void ConfigureServices(IAppBuilder app, System.Web.Http.HttpConfiguration config)
        {
            var cacheConfig = CacheManager.Core.ConfigurationBuilder.LoadConfiguration("ServicesCache");
            var builder     = new ContainerBuilder();

            builder
            .RegisterInstance(RabbitMQMessagingLogger.FromConfiguration())
            .SingleInstance();
            builder
            .RegisterInstance(CacheFactory.FromConfiguration <object>(cacheConfig))
            .SingleInstance();
            builder
            .RegisterInstance(CacheFactory.FromConfiguration <object>(CacheManager.Core.ConfigurationBuilder.LoadConfiguration("AppCache")))
            .Named <ICacheManager <object> >("AppCache")
            .SingleInstance();
            builder
            .RegisterInstance(CacheFactory.FromConfiguration <object>(CacheManager.Core.ConfigurationBuilder.LoadConfiguration("SessionStateStorage")))
            .Named <ICacheManager <object> >("SessionStateStorage")
            .SingleInstance();
            builder
            .Register(c => new DSS4_ECompliance.Hubs.EventsHub())
            .As <zAppDev.DotNet.Framework.Hubs.IApplicationHub>().SingleInstance();
            var repoBuilder = new RepositoryBuilder();

            builder
            .Register(c => repoBuilder)
            .As <zAppDev.DotNet.Framework.Data.DAL.IRepositoryBuilder>().SingleInstance();
            builder
            .Register(c => new zAppDev.DotNet.Framework.Workflow.WorkflowManager(repoBuilder))
            .As <zAppDev.DotNet.Framework.Workflow.WorkflowManager>().SingleInstance();
            builder
            .Register(c =>
            {
                var scheduleManager = new zAppDev.DotNet.Framework.Workflow.ScheduleManager(repoBuilder);
                zAppDev.DotNet.Framework.Workflow.ScheduleThread.NumberOfSessions = 0;
                zAppDev.DotNet.Framework.Workflow.ScheduleThread.Manager          = scheduleManager; // Inject Application Schedule Manager
                zAppDev.DotNet.Framework.Workflow.ScheduleThread.StartScheduleThread(HttpContext.Current);
                return(scheduleManager);
            })
            .As <zAppDev.DotNet.Framework.Workflow.ScheduleManager>().SingleInstance();
            builder
            .Register(c => new NHAuditTrailManager())
            .As <INHAuditTrailManager>().SingleInstance();
            builder
            .Register(c =>
            {
                return(new Security.Encryption.EncryptionManager());
            })
            .As <zAppDev.DotNet.Framework.Data.Encryption.Manager.EncryptionManagerBase>()
            .SingleInstance();
            builder
            .Register(c =>
            {
                PerformanceMonitorConfiguration monitorConfiguration = null;
                return(monitorConfiguration);
            })
            .SingleInstance();
            var container = builder.Build();
            var csl       = new AutofacServiceLocator(container);

            ServiceLocator.SetLocatorProvider(() => csl);
            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
        }