/// <summary>
 /// Unico metodo publico da classe que recebe uma string de conexao para configurar o nhibernate
 /// </summary>
 /// <param name="connString"></param>
 public static void ConfigureDataAccess(string connString)
 {
     //Chama o configurador do nhibernate utilizando o structuremap para fazer a injeção de dependencia
     ObjectFactory.Configure(i => ConfigureDataAccess(i, connString));
     //verifica se tudo foi configurado com sucesso
     ObjectFactory.AssertConfigurationIsValid();
 }
Exemple #2
0
        public static IContainer Initialize()
        {
            ObjectFactory.Initialize(x =>
            {
                x.Scan(scan =>
                {
                    scan.LookForRegistries();
                    scan.AssembliesFromApplicationBaseDirectory(a => a.FullName.StartsWith("Lending"));
                    scan.WithDefaultConventions();
                    //scan.TheCallingAssembly();
                });

                x.For <IRequestHandler <IAuthSession, BaseResponse> >()
                .AlwaysUnique()
                .Use <FormsAuthNewUserRequestHandler>()
                ;
            });

            ObjectFactory.AssertConfigurationIsValid();
            string blah = ObjectFactory.WhatDoIHave();

            //new SchemaUpdate(ObjectFactory.GetInstance<Configuration>())
            //    .Execute(true, true);

            return(ObjectFactory.Container);
        }
Exemple #3
0
        public void ConfigureService <T>(string[] args) where T : class, IServiceInterface
        {
            var cfg = RunnerConfigurator.New(c =>
            {
                c.SetServiceName(ServiceName);
                c.SetDisplayName(DisplayName);
                c.SetDescription(Description);

                c.RunAsLocalSystem();
                c.DependencyOnMsmq();

                c.ConfigureService <T>(s =>
                {
                    MsmqEndpointConfigurator.Defaults(def => def.CreateMissingQueues = true);
                    s.HowToBuildService(name =>
                    {
                        Container container = new Container(x =>
                        {
                            x.AddRegistry(new IocRegistry(SourceQueue, SubscriptionQueue));

                            ContainerSetup(x);
                        });

                        return(container.GetInstance <T>());
                    });

                    s.WhenStarted(start => start.Start());
                    s.WhenStopped(stop => stop.Stop());
                });
            });

            ObjectFactory.AssertConfigurationIsValid();

            Runner.Host(cfg, args);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            ObjectFactory.Initialize(x =>
            {
                x.Scan(y =>
                {
                    y.WithDefaultConventions();
                    y.LookForRegistries();
                    //y.AssembliesFromPath(Environment.CurrentDirectory, a => a.FullName.StartsWith("Lending"));
                    y.AssembliesFromPath(Environment.CurrentDirectory, Blah);
                });
            });

            ObjectFactory.AssertConfigurationIsValid();
            string blah = ObjectFactory.WhatDoIHave();

            SchemaUpdater.UpdateSchema();

            //using (var host = new NancyHost(new Uri("http://localhost:8080")))
            //{
            //    host.Start();
            //    Console.WriteLine("Nancy has started");
            //    Console.ReadLine();
            //}


            var host = new AppHost();

            host.Init();
            host.Start("http://localhost:8085/");
            Console.WriteLine("Listening, GO!");
            Console.ReadLine();
        }
 public virtual void BootstrapStructureMap()
 {
     ObjectFactory.Initialize(x =>
     {
         x.AddRegistry(new KYTWebRegistry());
     });
     ObjectFactory.AssertConfigurationIsValid();
 }
 public void TestConfiguration()
 {
     ObjectFactory.Initialize(config =>
     {
         config.AddRegistry(new CoreRegistry(this.Store));
     });
     ObjectFactory.AssertConfigurationIsValid();
 }
Exemple #7
0
        static void ConfigureStructureMap()
        {
            ObjectFactory.Initialize(x => x.AddRegistry <ExampleRegistry>());

            ObjectFactory.AssertConfigurationIsValid();

            _dependenciesRegistered = true;
        }
Exemple #8
0
        protected virtual void OnStart()
        {
            //Setup Ioc container and related services
            Bootstrap();

            // uncomment the following line if you wish to have StructureMap verify its configuration.  ASP.NET error page will be generated if configuration is incorrect.
            ObjectFactory.AssertConfigurationIsValid();
            System.Diagnostics.Debug.Write(ObjectFactory.WhatDoIHave());
        }
Exemple #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EnvironmentResolver"/> class.
        /// </summary>
        public EnvironmentResolver()
        {
            // Set up StructureMap and loading all the plugins from the
            // main directory.
            ObjectFactory.Initialize(InitializeStructureMap);
            string results = ObjectFactory.WhatDoIHave();

            Debug.WriteLine(results);
            ObjectFactory.AssertConfigurationIsValid();
        }
Exemple #10
0
        /// <summary> Registers the dependency injection. </summary>
        public static void Setup()
        {
            ObjectFactory.Initialize(x => x.Scan(s =>
            {
                x.For <ISession>().Use(CreateSessionFactory().OpenSession);

                s.TheCallingAssembly();
                s.WithDefaultConventions();
            }));

            ObjectFactory.AssertConfigurationIsValid();
        }
Exemple #11
0
        public void Will_be_able_to_re_create_the_database_schema_in_sqlite()
        {
            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry <DomainRegistry>();
                x.AddRegistry <ReportingRegistry>();
                x.AddRegistry <ServicesRegister>();
            });

            ObjectFactory.AssertConfigurationIsValid();

            ObjectFactory.ResetDefaults();
        }
Exemple #12
0
 public static void Restart()
 {
     if (_hasStarted)
     {
         ObjectFactory.ResetDefaults();
     }
     else
     {
         new Bootstrapper().BootstrapStructureMap(false);
         Debug.WriteLine(ObjectFactory.WhatDoIHave());
         ObjectFactory.AssertConfigurationIsValid();
         _hasStarted = true;
     }
 }
        public virtual void BootstrapStructureMap()
        {
            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry(new FrameworkServicesRegistry());
                x.AddRegistry(new AltOxiteWebRegistry());
                x.AddRegistry(new ControllerConfig());
            });

            ObjectFactory.AssertConfigurationIsValid();

            setup_service_locator();

            initialize_routes();
        }
Exemple #14
0
        /// <summary>
        /// Registers the dependency injection.
        /// </summary>
        private void RegisterDependencyInjection()
        {
            ObjectFactory.Initialize(x => x.Scan(s =>
            {
                x.For <ISession>().HttpContextScoped().Use(CreateSessionFactory().OpenSession);
                x.For <ITimezoneHydration>().Use <TimezoneHydration>();
                x.For <ITwillioService>().Use <TwillioService>();
                x.For <IDatabase>().Use(new MsSqlDatabase(key: "sql"));

                s.TheCallingAssembly();
                s.WithDefaultConventions();
            }));

            ObjectFactory.AssertConfigurationIsValid();
            DependencyResolver.SetResolver(new StructureMapDependencyResolver());
        }
        /// <summary> Registers the dependency injection. </summary>
        private void RegisterDependencyInjection()
        {
            var settings = MomntzConfiguration.GetSettings();

            SetLogging(settings);

            ObjectFactory.Initialize(x => x.Scan(s =>
            {
                x.AddRegistry <MomntzRegistry>();

                x.For <IDatabase>().Use(new MsSqlDatabase());
                x.For <ApplicationSettings>().Use(settings);

                x.For <ICrypto>().Use <Crypto>();
                x.For <ILog>().Use <Log>();
                x.For <IConfigurationService>().Use <MomntzConfiguration>();
                x.For <ISessionFactory>().Singleton().Use(Database.CreateSessionFactory);
                x.For <NHibernate.ISession>().HttpContextScoped().Use(r => r.GetInstance <ISessionFactory>().OpenSession());
                x.For <IStorage>().Use <AzureStorage>()
                .Ctor <string>("cloudUrl")
                .Is(settings.CloudUrl)
                .Ctor <string>("cloudAccount")
                .Is(settings.CloudAccount)
                .Ctor <string>("cloudKey")
                .Is(settings.CloudKey);

                x.For <IQueue>().Use <AzureQueue>()
                .Ctor <string>("connectionString")
                .Is(settings.ServiceBusEndpoint);

                s.TheCallingAssembly();
                s.WithDefaultConventions();

                s.ConnectImplementationsToTypesClosing(typeof(IFormHandler <>));
                s.ConnectImplementationsToTypesClosing(typeof(IQueryHandler <,>));

                x.For <IInjection>().Use(new StructureMapInjection());
            }));

            ModelBinders.Binders.Add(typeof(NewTag), new NewTagModelBinder());
            ModelBinders.Binders.Add(typeof(UsernameAndPassword), new UsernameAndPasswordModelBinder());

            ObjectFactory.AssertConfigurationIsValid();
            DependencyResolver.SetResolver(new StructureMapDependencyResolver());

            ConfigureAutoMapper();
        }
        public void BootstrapStructureMap()
        {
            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry(new FrameworkServicesRegistry());
                x.AddRegistry(new FubuSampleWebRegistry());
                x.AddRegistry(new ControllerConfig());
            });

            ObjectFactory.AssertConfigurationIsValid();

            setup_service_locator();

            apply_action_conventions();

            initialize_routes();
        }
        public void BootStrapTheApplication()
        {
            DomainDatabaseBootStrapper.BootStrap();
            ReportingDatabaseBootStrapper.BootStrap();

            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry <ApplicationRegistry>();
                x.AddRegistry <DomainRegistry>();
                x.AddRegistry <ReportingRegistry>();
                x.AddRegistry <ServicesRegister>();
            });
            ObjectFactory.AssertConfigurationIsValid();

            RegisterCommandHandlersInMessageRouter.BootStrap();
            RegisterEventHandlersInMessageRouter.BootStrap();
        }
Exemple #18
0
 public static IContainer Initialize()
 {
     ObjectFactory.Initialize(x =>
     {
         x.Scan(scan =>
         {
             scan.TheCallingAssembly();
             scan.AssemblyContainingType <IAsymmetricCryptographyApplicationService>();
             scan.AssemblyContainingType <IAsymmetricCryptographyService>();
             scan.AssemblyContainingType <IAsymmetricKeyRepository>();
             scan.WithDefaultConventions();
         });
         x.For <IAsymmetricCryptographyService>().Use <RsaCryptographyService>();
         x.For <IAsymmetricKeyRepositoryFactory>().Use <LazySingletonAsymmetricKeyRepositoryFactory>();
         x.For <ISymmetricEncryptionService>().Use <RijndaelSymmetricCryptographyService>();
     });
     ObjectFactory.AssertConfigurationIsValid();
     return(ObjectFactory.Container);
 }
Exemple #19
0
        protected void Application_Start()
        {
            ObjectFactory.Initialize(i => i.AddRegistry <StructureMapRegistry>());
            ObjectFactory.AssertConfigurationIsValid();
            ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Mapper.CreateMap <TwitterStatus, Tweet>();
            Mapper.CreateMap <Tweet, TwitterStatus>();
            Mapper.CreateMap <TwitterUser, User>();
            Mapper.CreateMap <User, TwitterUser>();
            Mapper.CreateMap <SearchViewModel, Search>();
            Mapper.CreateMap <Search, SearchViewModel>();
            Mapper.CreateMap <TwitterAppViewModel, TwitterApp>();
            Mapper.CreateMap <TwitterApp, TwitterAppViewModel>();

            Scheduler.Init();
        }
        /// <summary> Registers the dependency injection. </summary>
        public static void Setup()
        {
            ObjectFactory.Initialize(x => x.Scan(s =>
            {
                x.AddRegistry <MomntzRegistry>();
                x.For <IDatabase>().Use(new MsSqlDatabase());
                x.For <NHibernate.ISession>().Use(CreateSessionFactory().OpenSession);
                x.For <IConfigurationService>().Use <MomntzConfiguration>();

                //x.For<IProjectionProcessor>().Use<ProjectionProcessor>();

                s.TheCallingAssembly();
                s.WithDefaultConventions();

                s.ConnectImplementationsToTypesClosing(typeof(IFormHandler <>));
                s.ConnectImplementationsToTypesClosing(typeof(IQueryHandler <,>));

                x.For <IInjection>().Use(new StructureMapInjection());
            }));

            ObjectFactory.AssertConfigurationIsValid();
        }
        public void BootstrapStructureMap()
        {
            ControllerConfiguration.Configure();

            ObjectFactory.Initialize(x =>
            {
                x.Scan(s =>
                {
                    s.AssemblyContainingType <User>();
                    s.WithDefaultConventions();
                });
                x.AddRegistry(new FrameworkServicesRegistry());
                x.AddRegistry(new FubuMvcSampleApplicationRegistry());
                x.AddRegistry(new ControllerConfig());
            });

            ObjectFactory.AssertConfigurationIsValid();

            setup_service_locator();

            initializeRoutes();
        }
Exemple #22
0
        public void Will_be_able_to_re_create_the_database_schema_in_sqlite()
        {
            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry <ApplicationRegistry>();
                x.AddRegistry <ProductCatalogRegistry>();
                x.AddRegistry <DomainRegistry>();
                x.AddRegistry <ReportingRegistry>();
                x.AddRegistry <ServicesRegister>();
            });

            var mockRegionManager = new Mock <IRegionManager>();
            var mockRegion        = new Mock <IRegion>(MockBehavior.Loose);

            mockRegionManager.Setup(x => x.Regions["mainRegion"]).Returns(mockRegion.Object);
            var mockBus = new Mock <IBus>();

            ObjectFactory.Inject(mockRegionManager.Object);
            ObjectFactory.Inject(mockBus.Object);
            ObjectFactory.AssertConfigurationIsValid();

            ObjectFactory.ResetDefaults();
        }
Exemple #23
0
        public void ConfigureService <T>(string[] args) where T : class, IServiceInterface
        {
            IRunConfiguration cfg = RunnerConfigurator.New(c =>
            {
                c.SetServiceName(ServiceName);
                c.SetDisplayName(DisplayName);
                c.SetDescription(Description);

                c.RunAsLocalSystem();
                c.DependencyOnMsmq();

                c.ConfigureService <T>(typeof(T).Name, s =>
                {
                    MsmqEndpointConfigurator.Defaults(def => def.CreateMissingQueues = true);
                    s.CreateServiceLocator(() =>
                    {
                        Container container = new Container(x =>
                        {
                            x.AddRegistry(new IocRegistry(SourceQueue, SubscriptionQueue));

                            ContainerSetup(x);
                        });

                        IServiceLocator objectBuilder = new StructureMapObjectBuilder(container);
                        ServiceLocator.SetLocatorProvider(() => objectBuilder);
                        return(objectBuilder);
                    });

                    s.WhenStarted(start => start.Start());
                    s.WhenStopped(stop => stop.Stop());
                });
            });

            ObjectFactory.AssertConfigurationIsValid();

            Runner.Host(cfg, args);
        }
Exemple #24
0
 public static IContainer Initialize()
 {
     ObjectFactory.Initialize(x =>
     {
         x.Scan(scan =>
         {
             scan.TheCallingAssembly();
             scan.AssemblyContainingType <ICustomerRepository>();
             scan.AssemblyContainingType <CustomerRepository>();
             scan.AssemblyContainingType <ICustomerService>();
             scan.AssemblyContainingType <BusinessRule>();
             scan.WithDefaultConventions();
         });
         //x.For<IObjectContextFactory>().Use<LazySingletonObjectContextFactory>();
         x.For <IObjectContextFactory>().Use <HttpAwareOrmDataContextFactory>();
         x.For <IUnitOfWork>().Use <InMemoryUnitOfWork>();
         x.For <ICacheStorage>().Use <SystemRuntimeCacheStorage>();
         var customerService = x.For <ICustomerService>().Use <CustomerService>();
         x.For <ICustomerService>().Use <EnrichedCustomerService>().Ctor <ICustomerService>().Is(customerService);
         x.For <IConfigurationRepository>().Use <AppSettingsConfigurationRepository>();
     });
     ObjectFactory.AssertConfigurationIsValid();
     return(ObjectFactory.Container);
 }
Exemple #25
0
 public void should_run_assert_configuration_is_valid_without_exceptions()
 {
     Bootstrapper.Bootstrap();
     ObjectFactory.AssertConfigurationIsValid();
 }
Exemple #26
0
 public void CheckConfiguration()
 {
     ObjectFactory.AssertConfigurationIsValid();
 }
 public void Setup()
 {
     ObjectFactory.ResetDefaults();
     ObjectFactory.AssertConfigurationIsValid();
 }