예제 #1
0
파일: WorkerRole.cs 프로젝트: Costo/sketch
        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();
        }
예제 #2
0
파일: Program.cs 프로젝트: Costo/sketch
        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);
        }
예제 #3
0
파일: Module.cs 프로젝트: Costo/sketch
        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));
        }