Ejemplo n.º 1
0
        public override bool OnStart()
        {
            Trace.TraceInformation("Starting Worker Role");

            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            Database.DefaultConnectionFactory = new ConnectionFactory(Database.DefaultConnectionFactory);

            var profile = new AutoMapperProfile();
            Mapper.AddProfile(profile);
            Mapper.AssertConfigurationIsValid(profile.ProfileName);

            var container = new UnityContainer();
            var unityServiceLocator = new UnityServiceLocator(container);
            Microsoft.Practices.ServiceLocation.ServiceLocator.SetLocatorProvider(() => unityServiceLocator);
            ServiceLocator = Microsoft.Practices.ServiceLocation.ServiceLocator.Current;
            new Sketch.Core.Module().Init(container);
            new Module().Init(container);

            return base.OnStart();
        }
Ejemplo n.º 2
0
        private static void Initialize()
        {
            var profile = new AutoMapperProfile();
            Mapper.AddProfile(profile);
            Mapper.AssertConfigurationIsValid(profile.ProfileName);

            Database.DefaultConnectionFactory = new ConnectionFactory(Database.DefaultConnectionFactory);
            Database.SetInitializer<SketchDbContext>(null);
            Database.SetInitializer<EventStoreDbContext>(null);
            using (var sketchDbContext = new SketchDbContext())
            using (var eventStoreDbContext = new EventStoreDbContext())
            {
                if (!sketchDbContext.Database.Exists())
                {
                    ((IObjectContextAdapter)sketchDbContext).ObjectContext.CreateDatabase();

                    eventStoreDbContext.Database.ExecuteSqlCommand(((IObjectContextAdapter)eventStoreDbContext).ObjectContext.CreateDatabaseScript());
                }
            }

            var container = new UnityContainer();
            var unityServiceLocator = new UnityServiceLocator(container);
            Microsoft.Practices.ServiceLocation.ServiceLocator.SetLocatorProvider(() => unityServiceLocator);
            ServiceLocator = Microsoft.Practices.ServiceLocation.ServiceLocator.Current;
            new Core.Module().Init(container);
            new Module().Init(container);
        }
Ejemplo n.º 3
0
        public void Init(IUnityContainer container)
        {
            var profile = new AutoMapperProfile();
            Mapper.AddProfile(profile);
            Mapper.AssertConfigurationIsValid(profile.ProfileName);

            Func<DbContext> contextFactory = () => new SketchDbContext();

            container.RegisterType<ICommandHandler, DrawingSessionCommandHandler>("DrawingSessionCommandHandler");
            container.RegisterType<ICommandHandler, StockPhotoCommandHandler>("StockPhotoCommandHandler");

            container.RegisterType<IEventHandler, StockPhotoDenormalizer>("StockPhotoDenormalizer", new InjectionConstructor(contextFactory));
            container.RegisterType<IEventHandler, DrawingSessionDenormalizer>("DrawingSessionDenormalizer", new InjectionConstructor(contextFactory));

            container.RegisterType<IStockPhotoDao, StockPhotoDao>(new InjectionConstructor(contextFactory));
            container.RegisterType<IDrawingSessionDao, DrawingSessionDao>(new InjectionConstructor(contextFactory));
        }