public FrameworkRegistry(IBootstrapperConfiguration settings)
        {
            Scan(scanner =>
            {
                scanner.AssemblyContainingType(typeof(FluentValidation.AbstractValidator <>));
                scanner.AssemblyContainingType(typeof(BaseResponse));
                scanner.AssemblyContainingType(typeof(IRequestHandler <,>));

                scanner.AddAllTypesOf(typeof(FluentValidation.IValidator <>));
                scanner.AddAllTypesOf(typeof(IRequestHandler <,>));
                scanner.AddAllTypesOf(typeof(IRootRequestHandler <,>));
                scanner.AddAllTypesOf(typeof(IEventHandler <>));

                scanner.WithDefaultConventions();
            });

            For <IBootstrapperConfiguration>().Use(settings);

            // Messaging
            For <IRequestDispatcher>().Use(ctx => new RequestDispatcher(type => ctx.GetInstance(type)));
            For <IEventDispatcher>().Use(ctx => new EventDispatcher(type => ctx.GetAllInstances(type)));
            For(typeof(IRootRequestHandler <,>)).Use(typeof(RootRequestHandler <,>)); // Register default handler.
            // Decorate request handlers behaviour.
            var types = For(typeof(IRootRequestHandler <,>));

            types.DecorateAllWith(typeof(AppServices.Decorators.ValidatorHandler <,>));
            // End Messaging

            For <IFileClient>().Use(ctx => new LocalFileClient(settings.Storage_RootPath, settings.Storage_BaseUrl));
            For <ILogger>().Use(ctx => new ConsoleLogger());
            For <SmtpClient>().Use(() => SmtpClientFactory.CreateSmtpClient(settings));
        }
 /// <summary>
 /// Tells bootstrapper to start a job server with the given
 /// options that use the specified storage (not the global one) on
 /// application start and stop it automatically on application
 /// shutdown request.
 /// </summary>
 /// <param name="configuration">Configuration</param>
 /// <param name="storage">Job storage to use</param>
 /// <param name="options">Job server options</param>
 public static void UseServer(
     this IBootstrapperConfiguration configuration,
     JobStorage storage,
     BackgroundJobServerOptions options)
 {
     configuration.UseServer(() => new BackgroundJobServer(options, storage));
 }
        public static SqlServerStorage UseSqlServerStorage(this IBootstrapperConfiguration configuration, string nameOrConnectionString)
        {
            SqlServerStorage sqlServerStorage = new SqlServerStorage(nameOrConnectionString);

            configuration.UseStorage((AuditLogStorage)sqlServerStorage);
            return(sqlServerStorage);
        }
Example #4
0
        public static RedisStorage UseRedisStorage(
            this IBootstrapperConfiguration configuration)
        {
            var storage = new RedisStorage();

            configuration.UseStorage(storage);
            return(storage);
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UnityBootstrapper" /> class.
        /// </summary>
        /// <param name="configuration">The <see cref="IBootstrapperConfiguration" />.</param>
        public UnityBootstrapper(IBootstrapperConfiguration configuration)
            : base(configuration)
        {
            Guard.ArgumentIsNotNull(configuration, "configuration");

            Initialize();
            _initialized = true;
        }
        public static IBootstrapperConfiguration WithLightCore(this IBootstrapperConfiguration bootstrapper, IContainerBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException();
            }

            return(bootstrapper.AddPlugin(new BootstrapperLightCorePlugin(builder)));
        }
        public static void UseLamarActivator(this IBootstrapperConfiguration configuration, IContainer container)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            configuration.UseActivator(new LamarJobActivator(container));
        }
        public static MongoStorage UseMongoStorage(this IBootstrapperConfiguration configuration,
                                                   string connectionString,
                                                   string databaseName)
        {
            MongoStorage storage = new MongoStorage(connectionString, databaseName, new MongoStorageOptions());

            configuration.UseStorage(storage);

            return(storage);
        }
Example #9
0
        /// <summary>
        /// Tells the bootstrapper to use PostgreSQL as a job storage,
        /// that can be accessed using the given connection string or
        /// its name.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        /// <param name="nameOrConnectionString">Connection string or its name</param>
        public static PostgreSqlStorage UsePostgreSqlStorage(
            this IBootstrapperConfiguration configuration,
            string nameOrConnectionString)
        {
            var storage = new PostgreSqlStorage(nameOrConnectionString);

            configuration.UseStorage(storage);

            return(storage);
        }
        /// <summary>
        /// Tells the bootstrapper to use Redis as a job storage
        /// available at the specified host and port and store the
        /// data in db with number '0'.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        /// <param name="hostAndPort">Host and port, for example 'localhost:6379'</param>
        public static RedisStorage UseRedisStorage(
            this IBootstrapperConfiguration configuration,
            string hostAndPort)
        {
            var storage = new RedisStorage(hostAndPort);

            configuration.UseStorage(storage);

            return(storage);
        }
        public static MongoStorage UseMongoStorage(this IBootstrapperConfiguration configuration,
                                                   MongoClientSettings mongoClientSettings,
                                                   string databaseName)
        {
            var storage = new MongoStorage(mongoClientSettings, databaseName);

            configuration.UseStorage(storage);

            return(storage);
        }
        public static FirebirdStorage UseFirebirdStorage(
            this IBootstrapperConfiguration configuration,
            string nameOrConnectionString)
        {
            var storage = new FirebirdStorage(nameOrConnectionString);

            configuration.UseStorage(storage);

            return(storage);
        }
        public PersistenceRegistry(IBootstrapperConfiguration settings)
        {
            _settings = settings;

            For <IDbConnection>().Use("", ctx =>
            {
                var conn = new SqlConnection(settings.Database_Main_ConnectionString);
                conn.Open();
                return(conn);
            });
        }
Example #14
0
        public static FluentNHibernateJobStorage UseFluentNHibernateJobStorage(
            this IBootstrapperConfiguration configuration,
            string nameOrConnectionString, ProviderTypeEnum providerType, FluentNHibernateStorageOptions options = null)
        {
            var storage = FluentNHibernateStorageFactory.For(providerType, nameOrConnectionString, options);

            configuration.UseStorage(storage);


            return(storage);
        }
        /// <summary>
        /// Tells bootstrapper to start a job server with the given
        /// amount of workers on application start and stop it automatically
        /// on application shutdown request. Global job storage is being used.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        /// <param name="workerCount">Worker count</param>
        public static void UseServer(
            this IBootstrapperConfiguration configuration,
            int workerCount)
        {
            var options = new BackgroundJobServerOptions
            {
                WorkerCount = workerCount
            };

            configuration.UseServer(() => new BackgroundJobServer(options));
        }
Example #16
0
        /// <summary>
        /// Tells the bootstrapper to use SQL Server as a job storage
        /// with the given options, that can be accessed using the specified
        /// connection string or its name.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        /// <param name="nameOrConnectionString">Connection string or its name</param>
        /// <param name="options">Advanced options</param>
        public static SqlServerStorage UseSqlServerStorage(
            this IBootstrapperConfiguration configuration,
            string nameOrConnectionString,
            SqlServerStorageOptions options)
        {
            var storage = new SqlServerStorage(nameOrConnectionString, options);

            configuration.UseStorage(storage);

            return(storage);
        }
		public static MongoStorage UseMongoStorage(this IBootstrapperConfiguration configuration,
			MongoClientSettings mongoClientSettings,
			string databaseName,
			MongoStorageOptions options)
		{
			MongoStorage storage = new MongoStorage(mongoClientSettings, databaseName, options);

			configuration.UseStorage(storage);

			return storage;
		}
        /// <summary>
        /// Tells bootstrapper to start a job server with the given
        /// queues array on application start and stop it automatically
        /// on application shutdown request. Global job storage is being used.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        /// <param name="queues">Queues to listen</param>
        public static void UseServer(
            this IBootstrapperConfiguration configuration,
            params string[] queues)
        {
            var options = new BackgroundJobServerOptions
            {
                Queues = queues
            };

            configuration.UseServer(() => new BackgroundJobServer(options));
        }
Example #19
0
        public static RedisStorage UseRedisStorage(
            this IBootstrapperConfiguration configuration,
            string OptionString,
            int db)
        {
            var storage = new RedisStorage(OptionString, db);

            configuration.UseStorage(storage);

            return(storage);
        }
        /// <summary>
        /// Tells the bootstrapper to use Redis as a job storage with
        /// the given options, available at the specified host and port,
        /// and store the data in the given database number.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        /// <param name="hostAndPort">Host and port, for example 'localhost:6379'</param>
        /// <param name="db">Database number to store the data, for example '0'</param>
        /// <param name="options">Advanced storage options</param>
        public static RedisStorage UseRedisStorage(
            this IBootstrapperConfiguration configuration,
            string connectionString,
            int db,
            TimeSpan invisibilityTimeout)
        {
            var storage = new RedisStorage(connectionString, db, invisibilityTimeout);

            configuration.UseStorage(storage);

            return(storage);
        }
 public static AuditLogOrmType UseEntityFrameworkDbInterceptor(
     this IBootstrapperConfiguration configuration, Action<AuditableEntityModelBuilder> propertyMappings = null)
 {
     var ormType = new EntityFrameworkOrmType();
     DbInterception.Add(new EFAuditLogInterceptor());
     var mappingsConfig = new AuditableEntityModelBuilder();
     if (propertyMappings != null)
     {
         propertyMappings(mappingsConfig);
         ormType.AuditableEntityModelConfiguration = mappingsConfig.ModelConfiguration;
     }
     configuration.UseOrm(ormType);
     return ormType;
 }
        public static IBootstrapperConfiguration IncludeAssemblies(this IBootstrapperConfiguration config, string mask, IList <string> paths)
        {
            if (paths == null || paths.Count == 0)
            {
                return(config);
            }

            var files = GetAllFiles(mask, paths);

            foreach (var file in files)
            {
                try
                {
                    var assembly = Assembly.LoadFrom(file);
                    config.IncludeAssembly(assembly);
                }
                catch { }
            }
            return(config);
        }
        public static IBootstrapperConfiguration IncludeAssemblies(this IBootstrapperConfiguration config, string mask, string path = null, bool includeSubDirs = false)
        {
            if (String.IsNullOrWhiteSpace(path))
            {
                path = AppDomain.CurrentDomain.BaseDirectory;
            }

            var files = System.IO.Directory.EnumerateFiles(path, mask, includeSubDirs ? System.IO.SearchOption.AllDirectories : System.IO.SearchOption.TopDirectoryOnly);

            foreach (var file in files)
            {
                try
                {
                    var assembly = Assembly.LoadFrom(file);
                    config.IncludeAssembly(assembly);
                }
                catch { }
            }
            return(config);
        }
Example #24
0
        public void Start(IBootstrapperConfiguration settings)
        {
            if (IsBoostrapped)
            {
                return;
            }
            IsBoostrapped = true;

            _settings = settings;

            _container = new Container(cfg =>
            {
                cfg.AddRegistry(new FrameworkRegistry(_settings));
                cfg.AddRegistry(new PersistenceRegistry(_settings));
            });

            StaticContainer = _container;

            string whatDoIHave = _container.WhatDoIHave();  //For debuging purposes
            string x           = _container.WhatDidIScan(); //For debuging purposes
        }
Example #25
0
        private static ILifetimeScope ConfigureHangfire(IBootstrapperConfiguration config)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["Vabank.Db"].ConnectionString;

            config.UseDashboardPath("/admin/hangfire");
            var storageOptions = new SqlServerStorageOptions {
                QueuePollInterval = TimeSpan.FromSeconds(15)
            };

            config.UseStorage(new SqlServerStorage(connectionString, storageOptions));
            config.UseAuthorizationFilters(new AuthorizationFilter {
                Roles = "Admin"
            });
            var builder = new ContainerBuilder();

            builder.RegisterModule(new BackgroundServicesModule(VaBankServiceBus.Instance));
            var module = builder.Build();

            config.UseAutofacActivator(module);
            config.UseServer();
            return(module);
        }
 public static IBootstrapperConfiguration WithLightCore(this IBootstrapperConfiguration bootstrapper)
 {
     return(bootstrapper.AddPlugin(new BootstrapperLightCorePlugin(new ContainerBuilder())));
 }
 /// <summary>
 /// Tells bootstrapper to start a job server with default options
 /// on application start and stop it automatically on application
 /// shutdown request. Global job storage is being used.
 /// </summary>
 /// <param name="configuration">Configuration</param>
 public static void UseServer(this IBootstrapperConfiguration configuration)
 {
     configuration.UseServer(() => new BackgroundJobServer());
 }
Example #28
0
 public static void UseUnityActivator(this IBootstrapperConfiguration configuration, IUnityContainer container)
 {
     configuration.UseActivator(new UnityJobActivator(container));
 }
Example #29
0
 public static void UseAutofacActivator(
     this IBootstrapperConfiguration configuration,
     ILifetimeScope lifetimeScope, bool useTaggedLifetimeScope = true)
 {
     configuration.UseActivator(new AutofacJobActivator(lifetimeScope, useTaggedLifetimeScope));
 }
 public static MongoStorage UseMongoStorage(this IBootstrapperConfiguration configuration,
                                            MongoClientSettings mongoClientSettings,
                                            string databaseName)
 {
     return(UseMongoStorage(configuration, mongoClientSettings, databaseName, new MongoStorageOptions()));
 }