Example #1
0
        private EventFlowOptions()
        {
            UseServiceRegistration(new EventFlowIoCServiceRegistration());

            ModuleRegistration = new ModuleRegistration(this);
            ModuleRegistration.Register <ProvidedJobsModule>();
        }
Example #2
0
        internal static void RegisterAssemblyModules <TAppSettings>(this ContainerBuilder builder,
                                                                    IReloadingManager <TAppSettings> settings,
                                                                    Action <IModuleRegistration> additionalModules,
                                                                    params Assembly[] assemblies)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (assemblies == null)
            {
                throw new ArgumentNullException(nameof(assemblies));
            }

            var moduleType      = typeof(Autofac.Module);
            var internalBuilder = new ContainerBuilder();

            internalBuilder
            .RegisterAssemblyTypes(assemblies)
            .Where(t => moduleType.GetTypeInfo().IsAssignableFrom(t.GetTypeInfo()))
            .WithParameter(TypedParameter.From(settings))
            .As <IModule>();

            if (additionalModules != null)
            {
                var registration = new ModuleRegistration <TAppSettings>(settings, internalBuilder);

                additionalModules.Invoke(registration);
            }

            LoadModules(builder, internalBuilder);
        }
Example #3
0
        protected void Application_Start()
        {
            _serverCulture = (CultureInfo)CultureInfo.GetCultureInfo("en").Clone();
            _serverCulture.DateTimeFormat.ShortDatePattern   = "dd.MM.yyyy";
            _serverCulture.DateTimeFormat.DateSeparator      = ".";
            _serverCulture.DateTimeFormat.LongTimePattern    = "HH:mm:ss";
            _serverCulture.DateTimeFormat.ShortTimePattern   = "HH:mm";
            _serverCulture.DateTimeFormat.AMDesignator       = string.Empty;
            _serverCulture.DateTimeFormat.PMDesignator       = string.Empty;
            _serverCulture.NumberFormat.NumberGroupSeparator = "'";

            var unityContainer = InitUnityContainer();

            var unityDependencyResolver = new UnityDependencyResolver(unityContainer);

            DependencyResolver.SetResolver(unityDependencyResolver);

            AreaRegistration.RegisterAllAreas();

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());

            GlobalFilters.Filters.Add(new NoCacheFilterAttribute());

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            ModuleRegistration.RegisterAllModules(RouteTable.Routes, unityContainer, null);
        }
        // For more information on configuring authentication, please visit https://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Login/Index"),
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            var builder = new ContainerBuilder();

            // Register your MVC controllers. (MvcApplication is the name of
            // the class in Global.asax.)
            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            //builder.RegisterControllers(Assembly.GetExecutingAssembly());

            // OPTIONAL: Register model binders that require DI.
            builder.RegisterModelBinders(typeof(MvcApplication).Assembly);
            builder.RegisterModelBinderProvider();

            // OPTIONAL: Enable property injection into action filters.
            builder.RegisterFilterProvider();

            ModuleRegistration.RegisterApplicationObjects(builder);
            //builder.RegisterType<MyActionFilter>().PropertiesAutowired();

            // Set the dependency resolver to be Autofac.
            var container = builder.Build();

            app.UseAutofacMiddleware(container);  // 1 - setting up autofac middleware (Autofac.Integration.Owin.dll)

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
Example #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddHttpClient();
            //register Infrastructure classes
            services.AddHostedService <QueuedHostedService>();
            services.AddSingleton <IBackgroundTaskQueue, BackgroundTaskQueue>();
            services.AddSingleton <IPMemoryCache>();
            services.AddScoped <IIPDetailsBuffer, IPDetailsBuffer>();
            //Register DB Connection string
            services.AddDbContext <ApplicationContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); });

            services.AddTransient(FactoryRepositoryDecorator);
            services.AddTransient <JobRepository>();

            //Register types of external service dll
            ModuleRegistration.RegisterTypes(services);

            //Used a decorator pattern
            services.AddScoped(FactoryDecorator);
            services.AddScoped <IJobProgressService, JobProgressService>();
            services.AddScoped <IIPStackService, IPStackService>();

            services.AddControllers();
        }
 public DiscordConnection()
 {
     ModuleRegistration.Register(this);
     _client       = new ClientWebSocket();
     _lastSequence = 0;
 }
Example #7
0
 public ModuleRegistration_Tests()
 {
     Sut = new ModuleRegistration(A.Fake <IIocBuilder>());
 }
Example #8
0
 public void Application_Start()
 {
     ModuleRegistration.RegisterAllModules();
 }
 /// <summary>
 ///     Prevents a default instance of the <see cref="IocBuilder" /> class from being created.
 /// </summary>
 private IocBuilder()
 {
     UseServiceRegistration(new ServiceRegistration());
     ModuleRegistration = new ModuleRegistration(this);
 }