Пример #1
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            container.RegisterType <IUnitOfWork, MyDbContext>(new PerRequestLifetimeManager());
            container.RegisterType <DbContext, MyDbContext>(new PerRequestLifetimeManager());

            container.RegisterType <ApplicationUserManager>(new PerRequestLifetimeManager());
            container.RegisterType <IAuthenticationManager>(
                new InjectionFactory(c => HttpContext.Current.GetOwinContext().Authentication));
            container.RegisterType <ApplicationSignInManager>(new PerRequestLifetimeManager());

            container.RegisterType <IIdentityMessageService, EmailService>();

            RepositoriesRegistraton.Register(container);

            Services.Impl.Services.Register(container);

            container.RegisterType <IExportDataService, ExportDataServiceImpl>();

            container.RegisterType <IUriService>(new InjectionFactory(c => new UriServiceImpl(new HttpContextWrapper(HttpContext.Current))));

            container.RegisterType <IEmailService, EmailServiceImpl>();

            container.RegisterType <IMailGunConfig, ApiSecretsStorage>();

            container.RegisterType <IUserStore <User, int>, MyUserStore>();

            container.RegisterType <IPluginFactory, PluginFactoryImpl>();

            //TODO Automatically load all assemblies that start with JoinRpg.Experimental.Plugin.*
            container.RegisterTypes(AllClasses.FromLoadedAssemblies().Where(type => typeof(IPlugin).IsAssignableFrom(type)),
                                    WithMappings.FromAllInterfaces, WithName.TypeName);
        }
Пример #2
0
        public static void InjectAll(IUnityContainer container)
        {
            container.RegisterTypes(RepositoriesRegistraton.GetTypes(),
                                    WithMappings.FromAllInterfaces,
                                    WithName.Default);

            container.RegisterTypes(Services.Impl.Services.GetTypes(),
                                    WithMappings.FromAllInterfaces,
                                    WithName.Default);

            container.RegisterType <IExportDataService, ExportDataServiceImpl>();


            container.RegisterType <IEmailService, EmailServiceImpl>();


            container.RegisterType <IPluginFactory, PluginFactoryImpl>();

            container.RegisterType <IEmailSendingService, EmailSendingServiceImpl>();

            //TODO Automatically load all assemblies that start with JoinRpg.Experimental.Plugin.*
            container.RegisterTypes(
                AllClasses.FromLoadedAssemblies()
                .Where(type => typeof(IPlugin).IsAssignableFrom(type)),
                WithMappings.FromAllInterfaces,
                WithName.TypeName);

            container.RegisterTypes(Registration.GetTypes(),
                                    WithMappings.FromAllInterfaces,
                                    WithName.Default);
        }
Пример #3
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterTypes(RepositoriesRegistraton.GetTypes().ToArray()).AsImplementedInterfaces();
            builder.RegisterTypes(Services.Impl.Services.GetTypes().ToArray()).AsImplementedInterfaces();
            builder.RegisterTypes(WebPortal.Managers.Registration.GetTypes().ToArray()).AsSelf();

            builder.RegisterType <ExportDataServiceImpl>().As <IExportDataService>();
            builder.RegisterType <EmailServiceImpl>().As <IEmailService>();
            builder.RegisterType <EmailSendingServiceImpl>().As <IEmailSendingService>();

            builder.RegisterType <PluginFactoryImpl>().As <IPluginFactory>();

            builder.RegisterType <MyDbContext>().AsSelf().AsImplementedInterfaces().InstancePerDependency();

            base.Load(builder);
        }
        protected override void Load(ContainerBuilder builder)
        {
            _ = builder.RegisterTypes(RepositoriesRegistraton.GetTypes().ToArray()).AsImplementedInterfaces();
            _ = builder.RegisterTypes(Services.Impl.Services.GetTypes().ToArray()).AsImplementedInterfaces();
            _ = builder.RegisterTypes(WebPortal.Managers.Registration.GetTypes().ToArray()).AsSelf();

            _ = builder.RegisterType <ExportDataServiceImpl>().As <IExportDataService>();
            _ = builder.RegisterType <EmailServiceImpl>().As <IEmailService>();
            _ = builder.RegisterType <EmailSendingServiceImpl>().As <IEmailSendingService>();

            _ = builder.RegisterType <MyDbContext>()
                .AsSelf()
                .AsImplementedInterfaces()
                .InstancePerDependency()
                .UsingConstructor(typeof(IJoinDbContextConfiguration));

            _ = builder.RegisterType <VirtualUsersService>().As <IVirtualUsersService>().SingleInstance();

            _ = builder.RegisterType <PaymentsService>().As <IPaymentsService>();

            base.Load(builder);
        }