Esempio n. 1
0
        public static Action <IContainer, MigrationCustomizer> InitializeAndGetMigrator(
            IContainerSetup s,
            Func <ISqlConnectionStringProvider> connectionStringProviderFactory,
            params Assembly[] entitiesOrigin)
        {
            s.For <ISqlConnectionStringProvider>().Import.FromFactory(locator => connectionStringProviderFactory());

            s.For <IDataModelHelper>().Use <CachedDataModelHelper>();
            s.For <ITransactionManager <SqlConnection> >().Use <ConnectionCreator>();
            s.For <IDatabase>().Use <Database>();
            s.For <ISchemaMigrator>().Use <SchemaMigrator>();
            s.For <IEntityNamingConvention>().Use <DefaultEntityNamingConvention>();

            foreach (var assembly in entitiesOrigin)
            {
                s.ScanAssembly(assembly);
            }

            Action <IContainer, MigrationCustomizer> migratorFunc = (container, customizer) =>
            {
                var sqlScriptGenerator = new SqlMigrationScriptBuilder();
                var hashBuilder        = new MigrationHashBuilder();
                var proxy = new ScriptBuilderProxy(hashBuilder, sqlScriptGenerator);

                if (customizer != null)
                {
                    proxy.AddCustomScript(customizer.BeforeMigrationScript, customizer.AfterMigrationScript);
                }

                using (var locator = container.GetLocator())
                {
                    var migrator = locator.Get <ISchemaMigrator>();
                    migrator.MigrateStructure(locator, proxy);

                    var hash   = hashBuilder.GetHash();
                    var script = sqlScriptGenerator.ToString(hash);

                    var connectionBuilder = locator.Get <ITransactionManager <SqlConnection> >();

                    using (var connection = connectionBuilder.Open(false))
                    {
                        using (var command = new SqlCommand(script, connection.GetConnection()))
                        {
                            command.CommandTimeout = 1000000;
                            command.ExecuteNonQuery();
                        }

                        connection.Commit();
                    }

                    if (!string.IsNullOrWhiteSpace(customizer.ScriptsRoot))
                    {
                        ScriptsMigrator.RunScripts(connectionBuilder, customizer.ScriptsRoot);
                    }
                }
            };

            return(migratorFunc);
        }
Esempio n. 2
0
 private static void LoadContainer()
 {
     lock (Triowing)
     {
         if(IocFactory!=null) return;
         IocFactory = new StardustIocFactory();
     }
 }
Esempio n. 3
0
 internal static void LoadContainer(IContainerSetup containerSetup)
 {
     lock (Triowing)
     {
         if(IocFactory!=null) throw new InvalidOperationException("Container factory already created");
         IocFactory = containerSetup;
     }
 }
Esempio n. 4
0
 internal static void LoadContainer(IBlueprint config)
 {
     // ReSharper disable once SuspiciousTypeConversion.Global 
     lock (Triowing)
     {
         if (IocFactory != null) return;
         IocFactory = config as IContainerSetup ?? new StardustIocFactory(); 
     }
 }
Esempio n. 5
0
        public void Setup(IContainerSetup setup)
        {
            //AsyncLogger.Initialize(new ConnectionStringProvider());

            setup.For <IConfigurationRepository>().Use <ConfigurationRepository>();
            setup.For <ILog>().Use <Logger>();
            setup.For <ICache>().Use <Cache>();
            setup.For <IPerProjectDbCache>().Use <PerProjectDbCache>();
            setup.For <ISysCountersManager>().Use <SysCounterManager>();
        }
Esempio n. 6
0
 private static void LoadContainer()
 {
     lock (Triowing)
     {
         if (IocFactory != null)
         {
             return;
         }
         IocFactory = new StardustIocFactory();
     }
 }
Esempio n. 7
0
 internal static void LoadContainer(IContainerSetup containerSetup)
 {
     lock (Triowing)
     {
         if (IocFactory != null)
         {
             throw new InvalidOperationException("Container factory already created");
         }
         IocFactory = containerSetup;
     }
 }
Esempio n. 8
0
        public void Setup(Type markedType, IContainerSetup setup)
        {
            if (!setup.GetRegisteredPlugins <ControllerCollectorPlugin>().Any())
            {
                setup.RegisterPlugin(s => s.CustomInstanceCreators.Add(new ControllerCollectorPlugin()));
            }

            setup.For(markedType)
            .Use(markedType)
            .WithBehavior <ControllerBehavior>(SetupBehavior);
        }
Esempio n. 9
0
 internal static void LoadContainer(IBlueprint config)
 {
     // ReSharper disable once SuspiciousTypeConversion.Global
     lock (Triowing)
     {
         if (IocFactory != null)
         {
             return;
         }
         IocFactory = config as IContainerSetup ?? new StardustIocFactory();
     }
 }
Esempio n. 10
0
        public void Setup(Type markedType, IContainerSetup setup)
        {
            if (!setup.GetRegisteredPlugins <EntityPlugin>().Any())
            {
                setup.RegisterPlugin(p => p.CustomInstanceCreators.Add(new EntityPlugin(new DefaultRobOrmSetup())));
            }

            if (!setup.GetRegisteredPlugins <EntityCollectorPlugin>().Any())
            {
                setup.RegisterPlugin(p => p.CustomInstanceCreators.Add(new EntityCollectorPlugin()));
                setup.For <IEntityCollector>();
            }

            var entityName = EntityName;

            if (string.IsNullOrWhiteSpace(entityName))
            {
                entityName = NamingHelper.GetDefaultEntityName(markedType);
            }

            var pkProperty = PrimaryKeyProperty;

            if (string.IsNullOrWhiteSpace(pkProperty))
            {
                pkProperty = "Id";
            }

            if (ReflectionUtil.GetProperty(markedType, pkProperty) == null)
            {
                throw new InvalidOperationException($"{markedType.Name} - Primary Key property \"{pkProperty}\" not found");
            }

            setup.For(markedType)
            .WithBehavior <EntityBehavior>(db =>
            {
                db.EntityName         = entityName;
                db.PrimaryKeyProperty = pkProperty;
            })
            .WithBehavior <LifecycleBehavior>(lb => lb.AlwaysNewInstance = true)
            .WithBehavior <DisposeBehavior>(db => db.Dispose             = false);
        }
Esempio n. 11
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IErpClientFactory>().Use <ErpClientFactory>();
     setup.For <IPurchaseOrderRepository>().Use <PurchaseOrderRepository>();
     setup.For <ICurrencyRepository>().Use <CurrencyRepository>();
     setup.For <IProductRepository>().Use <ProductRepository>();
     setup.For <IOrderStatusMappingRepository>().Use <OrderStatusMappingRepository>();
     setup.For <IOrderStatusTranslator>().Use <OrderStatusTranslator>();
     setup.For <IOrderStatusRepository>().Use <OrderStatusRepository>();
     setup.For <IPaymentRepository>().Use <PaymentRepository>();
     setup.For <IOrdersFacade>().Use <OrdersFacade>();
     setup.For <IVirtualProductRepository>().Use <VirtualProductRepository>();
     setup.For <IErpRepository>().Use <ErpRepository>();
     setup.For <IUnitRepository>().Use <UnitRepository>();
     setup.For <IUnitConversionHelper>().Use <UnitConversionHelper>();
     setup.For <IMaterialRepository>().Use <MaterialRepository>();
     setup.For <IVirtualProductFacade>().Use <VirtualProductFacade>();
     setup.For <IMaterialFacade>().Use <MaterialFacade>();
     setup.For <IKitProductRepository>().Use <KitProductRepository>();
     setup.For <ICustomerRepository>().Use <CustomerRepository>();
     setup.For <IUserRepository>().Use <UserRepository>();
     setup.For <IMaterialBatchRepository>().Use <MaterialBatchRepository>();
     setup.For <IMaterialBatchFacade>().Use <MaterialBatchFacade>();
     setup.For <AmountProcessor>().Use <AmountProcessor>();
     setup.For <IPackingPreferredBatchRepository>().Use <PreferredBatchRepository>();
     setup.For <IProductionFacade>().Use <ProductionFacade>();
     setup.For <IBatchReportingFacade>().Use <BatchReportingFacade>();
     setup.For <IMaterialThresholdRepository>().Use <MaterialThresholdRepository>();
     setup.For <IStockEventRepository>().Use <StockEventRepository>();
     setup.For <ISupplierRepository>().Use <SupplierRepository>();
     setup.For <ICurrencyConversionHelper>().Use <CurrencyConversionHelper>();
     setup.For <IRepositoryFactory>().Use <RepositoryFactory>();
     setup.For <IFixedCostRepository>().Use <FixedCostRepository>();
     setup.For <ISaleEventRepository>().Use <SaleEventRepository>();
     setup.For <IRecipeRepository>().Use <RecipeRepository>();
     setup.For <IOrderWeightCalculator>().Use <OrderWeightCalculator>();
 }
Esempio n. 12
0
 public static void LoadIocContainer(IContainerSetup containerSetup)
 {
     HasExternalIoc = true;
     KernelFactory.LoadContainer(containerSetup);
 }
Esempio n. 13
0
 public void Setup(IContainerSetup setup)
 {
 }
Esempio n. 14
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IShipmentProvider>().Use <ZasilkovnaClient>();
 }
Esempio n. 15
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IParametersResolver>().Use <ParametersResolver>();
     setup.For <AutoProceduresJob>().Use <AutoProceduresJob>();
 }
Esempio n. 16
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <EventModelProcessor>().Use <EventModelProcessor>();
 }
Esempio n. 17
0
 public void Setup(Type markedType, IContainerSetup setup)
 {
     setup.For(markedType).ImportObject.FromFactory(locator => ConfigFactory(locator, markedType));
 }
Esempio n. 18
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <ElsaExcelModelFactory>().Use <ElsaExcelModelFactory>();
 }
Esempio n. 19
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IInvoiceFormGeneratorFactory>().Use <InvoiceFormGeneratorFactory>();
     setup.For <IInvoiceFormsGenerationRunner>().Use <InvoiceFormsGenerationRunner>();
 }
Esempio n. 20
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <FloxDataMapper>().Use <FloxDataMapper>();
 }
Esempio n. 21
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IInvoiceFormsRepository>().Use <InvoiceFormRepository>();
 }
Esempio n. 22
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IUserRepository>().Use <UserRepository>();
     setup.For <IUserRoleRepository>().Use <UserRepository>();
     setup.For <IUserManagementFacade>().Use <UserManagementFacade>();
 }
Esempio n. 23
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IProductionService>().Use <Service.ProductionService>();
     setup.For <IRecipeService>().Use <RecipeService>();
 }
Esempio n. 24
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <InvoiceFormsQueryingFacade>().Use <InvoiceFormsQueryingFacade>();
     setup.For <IInvoiceFormRendererFactory>().Use <InvoiceFormRendererFactory>();
 }
Esempio n. 25
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IPaymentSystemClientFactory>().Use <PaymentSystemClientFactory>();
 }
Esempio n. 26
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IStockReportLoader>().Use <StockReportLoader>();
 }
Esempio n. 27
0
 public void Setup(Type markedType, IContainerSetup setup)
 {
     UserRights.RegisterType(markedType);
 }
Esempio n. 28
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IMailSender>().Use <SmtpMailSender>();
     setup.For <IRecipientListsRepository>().Use <RecipientListsRepository>();
 }
Esempio n. 29
0
 public void Setup(IContainerSetup setup)
 {
     //setup.ScanAssembly(typeof(ProfileController).Assembly);
 }
Esempio n. 30
0
 protected virtual void RegisterControllerNameExtractor(IContainerSetup setup)
 {
     setup.For <IControllerNameExtractor>().Use <DefaultControllerNameExtractor>();
 }
Esempio n. 31
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <ElerpClient>().Use <ElerpClient>();
 }
Esempio n. 32
0
 public void Setup(IContainerSetup setup)
 {
     setup.For <IInspectionsRepository>().Use <InspectionsRepository>();
 }
Esempio n. 33
0
 public void Setup(Type markedType, IContainerSetup setup)
 {
     setup.For(markedType).Use(m_implementingType);
 }