示例#1
0
        public static void RegisterServices(Container container)
        {
            //Identity
            container.Register<UnitOfWorkIdentity>(Lifestyle.Scoped);
            container.Register<IUnitOfWorkIdentity, UnitOfWorkIdentity>(Lifestyle.Scoped);
            container.RegisterPerWebRequest<IUserStore<IdentityUser>>(() => new UserStore<IdentityUser>(new UnitOfWorkIdentity()));

            container.Register<ApplicationUserManager>(Lifestyle.Scoped);
            container.Register<ApplicationSignInManager>(Lifestyle.Scoped);

            //ApplicationServices
            container.Register(typeof(IAppService<>), typeof(AppService<>), Lifestyle.Scoped);

            container.Register<IInstitutionAppService, InstitutionAppService>(Lifestyle.Scoped);

            //UnitOfWork
            container.Register<UnitOfWork>(Lifestyle.Scoped);
            container.RegisterPerWebRequest<IUnitOfWork, UnitOfWork>();

            //Repositories
            container.Register(typeof(IRepository<>), typeof(Repository<>), Lifestyle.Scoped);

            container.Register<IInstitutionRepository, InstitutionRepository>(Lifestyle.Scoped);

            //Services
            container.Register(typeof(IService<>), typeof(Service<>), Lifestyle.Scoped);

            container.Register<IInstitutionService, InstitutionService>(Lifestyle.Scoped);
        }
 private static void InitializeContainer(Container container)
 {
     container.RegisterPerWebRequest<IConfigurationHelper, ConfigurationHelper>();
       container.RegisterPerWebRequest<ISecurityManager, SecurityManager>();
       container.RegisterPerWebRequest<IChatRepository, MongoChatRepository>();
       container.RegisterPerWebRequest<ChatHub>();
 }
 public void RegisterServices(Container container)
 {
     container.RegisterPerWebRequest<IUserStore<User>>(() => new UserStore<User>(container.GetInstance<IdentityDbContext<User>>()));
     container.RegisterPerWebRequest(() => container.IsVerifying()
         ? new OwinContext(new Dictionary<string, object>()).Authentication
         : HttpContext.Current.GetOwinContext().Authentication);
 }
 public static void Config(Container container)
 {
     container.RegisterPerWebRequest<IDatabaseFactory,DatabaseFactory>();
     container.RegisterOpenGeneric(typeof(IRepository<>), typeof(Repository<>));
     container.RegisterPerWebRequest<IUnitOfWork, UnitOfWork>();
     container.Register<IProductRepository, ProductRepository>();
     container.Register(()=>new SrcSamples());
 }
示例#5
0
        public void RegisterServices(Container container)
        {
            container.RegisterPerWebRequest(() => new BloggableDbContext(AppSettingConstants.DefaultDbConnectionName));
            container.RegisterPerWebRequest<DbContext>(container.GetInstance<BloggableDbContext>);
            container.RegisterPerWebRequest<IdentityDbContext<User>>(container.GetInstance<BloggableDbContext>);

            container.RegisterOpenGeneric(typeof(IDeletableEntityRepository<>), typeof(EfDeletableEntityRepository<>));
            container.RegisterOpenGeneric(typeof(IRepository<>), typeof(EfRepository<>));
        }
        public void RegisterServices(Container container)
        {
            var documentDbAppKey = ConfigurationManager.AppSettings["DocumentDbAppKey"];
            var documentDbUri = ConfigurationManager.AppSettings["DocumentDbUri"];

            Logger.InfoFormat("DocumentDbAppKey: {0}, DocumentDbUri: {1}", documentDbAppKey, documentDbUri);

            container.RegisterPerWebRequest<IMessageRepository, DocumentDbMessageRepository>();
            container.RegisterPerWebRequest<IMessageCounter>(() => new DocumentDbMessageCounter(documentDbUri, documentDbAppKey));
        }
示例#7
0
        private static void InitializeContainer(Container container)
        {
            // DbContext, UoW & Repository
            container.RegisterPerWebRequest<DbContext, SharedPicDbContext>();
            container.RegisterPerWebRequest<IUnitOfWork, UnitOfWork>();
            container.Register<IRepository, GenericRepository>();

            // Services
            // TODO
        }
 private static void InitializeContainer(Container container)
 {
     container.RegisterPerWebRequest<IDbConnection>(CreateConnection);
     container.RegisterSingle<Logger>();
     container.Register<IDbCommand>(() => new SqlCommand(string.Empty,container.GetInstance<IDbConnection>() as SqlConnection));
     container.RegisterPerWebRequest<IContactRepository, ContactRepository>();
     //container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), typeof(Contact).Assembly);
     container.RegisterPerWebRequest<ICommandHandler<CreateContactCommand>, CreateContactHandler>();
     container.RegisterDecorator(typeof (ICommandHandler<>), typeof (CommandAuditingHandler<>));
     container.Register<UnitOfWork>();
 }
示例#9
0
        private static void RegisterRavenDB(Container container)
        {
            var store = new DocumentStore { ConnectionStringName = "Server" };

            store.Initialize();

            container.RegisterSingle<IDocumentStore>(store);

            container.RegisterPerWebRequest<IAsyncDocumentSession>(() => store.OpenAsyncSession());

            container.RegisterPerWebRequest<IDocumentSession>(() => store.OpenSession());
        }
        public void RegisterServices(Container container)
        {
            container.RegisterSingleton<IDocumentStore>(() =>
            {
                var url = ConfigurationManager.AppSettings["RavenDbUrl"];
                var apiKey = ConfigurationManager.AppSettings["RavenDbApiKey"];
                return DocumentStoreManager.GetCurrent(url, apiKey);
            });

            container.RegisterPerWebRequest<IMessageCounter, RavenDbMessageCounter>();
            container.RegisterPerWebRequest<IMessageRepository, RevenDbMessageRepository>();
        }
        public static void Configure()
        {
            Container = new Container();

            Container.Register(() => HttpContext.Current.GetOwinContext());
            Container.RegisterPerWebRequest(()=> Container.GetInstance<IOwinContext>().Authentication);
            Container.RegisterPerWebRequest(() => AppUserManager.Create(new IdentityFactoryOptions<AppUserManager>(), Container.GetInstance<IOwinContext>()));
            Container.RegisterPerWebRequest(AppDbContext.Create);
            Container.RegisterPerWebRequest<DbContext>(() => Container.GetInstance<AppDbContext>());

            RepositoryRegistry.InsertIn(Container);
        }
示例#12
0
        public void Register(Container container)
        {
            container.RegisterSingle<IUserStore<ApplicationUser, Guid>, ApplicationUserStore>();
            container.RegisterSingle<IIdentityMessageService, ApplicationIdentityMessageService>();
            container.RegisterSingle<ApplicationUserManager>();

            container.RegisterPerWebRequest<ApplicationSignInManager>();
            container.RegisterPerWebRequest<IUserContext, UserContext>();
            container.RegisterPerWebRequest<IContextService, ContextService>();

            container.RegisterMvcIntegratedFilterProvider();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
示例#13
0
        public static void RegisterServices(Container container)
        {
            //App
            container.RegisterPerWebRequest<IClienteAppService, ClienteAppService>();

            //Domain
            container.RegisterPerWebRequest<IClienteService, ClienteService>();

            //infra
            container.RegisterPerWebRequest<IClienteRepository, ClienteRepository>();
            container.RegisterPerWebRequest<DDDContext>();

            //container.RegisterPerWebRequest<IUnitOfWork, UnitOfWork>();
        }
        public static void Initialize()
        {
            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            // Chamada dos módulos do Simple Injector
            InitializeContainer(container);

            // Necessário para registrar o ambiente do Owin que é dependência do Identity
            // Feito fora da camada de IoC para não levar o System.Web para fora
            container.RegisterPerWebRequest(() =>
            {
                if (HttpContext.Current != null && HttpContext.Current.Items["owin.Environment"] == null && container.IsVerifying())
                {
                    return new OwinContext().Authentication;
                }
                return HttpContext.Current.GetOwinContext().Authentication;

            });

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
示例#15
0
        /// <summary>
        /// Initialises IoC on the website
        /// </summary>
        public static void Initialise()
        {
            var container = new Container();
            container.Options.ConstructorResolutionBehavior =
                new T4MvcControllerConstructorResolutionBehavior(container.Options.ConstructorResolutionBehavior);

            // Register the MVC controls
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcAttributeFilterProvider();
            container.Register<ITempDataProvider, CookieTempDataProvider>();

            // The other MVC stuff
            //container.Register<ITempDataProvider, CookieTempDataProvider>();
            // Register the other ASP.NET MVC stuff
            // TODO: Figure out how to do this properly - http://simpleinjector.codeplex.com/discussions/430939
            //container.RegisterPerWebRequest<RequestContext>(() => HttpContext.Current.Request.RequestContext);
            //container.RegisterPerWebRequest<UrlHelper>(() => new UrlHelper(container.GetInstance<RequestContext>()));

            container.RegisterPerWebRequest<IWebCache>(config => config.WebCacheType);

            // Initialise all the standard stuff
            Ioc.Initialise(container, new WebRequestLifestyle());

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
        public static void Initialize()
        {
            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            InitializeContainer(container);

            container.RegisterPerWebRequest(() =>
            {
                if (HttpContext.Current != null && HttpContext.Current.Items["owin.Enviroment"] == null && container.IsVerifying)
                {
                    return new OwinContext().Authentication;
                }

                return HttpContext.Current.GetOwinContext().Authentication;
            });

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterWebApiControllers(GlobalConfiguration.Configuration);

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
            GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
        }
示例#17
0
 public static void RegisterServices(Container container)
 {
     container.Register<ApplicationDbContext>(Lifestyle.Scoped);
     container.RegisterPerWebRequest<IUserStore<ApplicationUser>>(() => new UserStore<ApplicationUser>(new ApplicationDbContext()));
     container.Register<ApplicationUserManager>(Lifestyle.Scoped);
     container.Register<ApplicationSignInManager>(Lifestyle.Scoped);
 }
        public static void Register(HttpConfiguration config)
        {
            using (var container = new Container())
            {
                container.Options.DefaultScopedLifestyle = new WebApiRequestLifestyle();

                // Chamada dos módulos do Simple Injector
                BootStrapper.RegisterServices(container);

                // Necessário para registrar o ambiente do Owin que é dependência do Identity
                // Feito fora da camada de IoC para não levar o System.Web para fora
                container.RegisterPerWebRequest(() =>
                {
                    if (HttpContext.Current != null && HttpContext.Current.Items["owin.Environment"] == null && container.IsVerifying())
                    {
                        return new OwinContext().Authentication;
                    }
                    return HttpContext.Current.GetOwinContext().Authentication;

                });

                // This is an extension method from the integration package.
                container.RegisterWebApiControllers(config);

                container.Verify();

                GlobalConfiguration.Configuration.DependencyResolver =
                    new SimpleInjectorWebApiDependencyResolver(container);
            }
        }
示例#19
0
        private static void InitializeContainer(Container container)
        {
            // DbContext, UoW & Repository
            container.RegisterPerWebRequest<DbContext, ContactsBookDBContext>();
            container.RegisterPerWebRequest<IUnitOfWork, UnitOfWork>();
            container.Register<IRepository, GenericRepository>();
            //container.Register<IPersonService, PersonService>();
            container.Register<IAddressService, AddressService>();
            container.Register<IEmailService,ContactsBook.Services.EmailService>();
            container.Register<IPhoneService, PhoneService>();
            //container.Register<IAddressTypeService, AddressTypeService>();
            //container.Register<IEmailTypeService, EmailTypeService>();
            //container.Register<IPhoneTypeService, PhoneTypeService>();
            container.Register<IGenericService, GenericService>();

            // Services
            // TODO
        }
示例#20
0
        private static void InitializeContainer(Container container)
        {
            // DbContext, UoW & Repository
            container.RegisterPerWebRequest<DbContext, PastedDbContext>();
            container.RegisterPerWebRequest<IUnitOfWork, UnitOfWork>();
            container.Register<IRepository, GenericRepository>();

            // Register all services as their implementing interfaces
            var registrations = ServicesAssembly.GetExportedTypes()
                .Where(t => t.Namespace == "Pasted.Services" && t.GetInterfaces().Any())
                .Select(t => new { Interface = t.GetInterfaces().Single(), Implementation = t });

            foreach (var registration in registrations)
            {
                container.Register(registration.Interface, registration.Implementation);
            }

            // TODO
        }
示例#21
0
        public static void RegisterServices(Container container)
        {
            container.RegisterPerWebRequest<ContextoIdentity>();
            container.RegisterPerWebRequest<IUserStore<ApplicationUser>>(() => new UserStore<ApplicationUser>(new ContextoIdentity()));
            container.RegisterPerWebRequest<IRoleStore<IdentityRole, string>>(() => new RoleStore<IdentityRole>());
            container.RegisterPerWebRequest<ApplicationRoleManager>();
            container.RegisterPerWebRequest<ApplicationUserManager>();
            container.RegisterPerWebRequest<ApplicationSignInManager>();

            container.RegisterPerWebRequest<IUsuarioRepository, UsuarioRepository>();
            container.RegisterPerWebRequest<IUsuarioService, UsuarioService>();
        }
 public static void RegisterServices(Container container)
 {
     container.RegisterPerWebRequest<ApplicationDbContext>();
     container.RegisterPerWebRequest<IUserStore<ApplicationUser>>(() => new UserStore<ApplicationUser>(new ApplicationDbContext()));
     container.RegisterPerWebRequest<IRoleStore<IdentityRole, string>>(() => new RoleStore<IdentityRole>());
     container.RegisterPerWebRequest<ApplicationRoleManager>();
     container.RegisterPerWebRequest<ApplicationUserManager>();
     container.RegisterPerWebRequest<ApplicationSignInManager>();
     container.RegisterPerWebRequest<ISecureDataFormat<AuthenticationTicket>>(() => new FakeTicket());
     
     container.RegisterPerWebRequest<IUsuarioRepository, UsuarioRepository>();
 } 
        public static Container Build()
        {
            var container = new Container();
            container.RegisterPerWebRequest<IDbContext>(() => new AppDbContext("AppDb"));
            container.RegisterPerWebRequest<ICurrentUser,FormsAuthenticationCurrentUser>();
            container.RegisterSingle<ICacheProvider,AppCacheProvider>();
            container.Register<ILogger,NLogLogger>();

            container.RegisterManyForOpenGeneric(typeof(IGridModelBuilder<,>), typeof(IGridModelBuilder<,>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IModelBuilder<>), typeof(IModelBuilder<>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IModelBuilder<,>), typeof(IModelBuilder<,>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IModelHandler<>), typeof(IModelHandler<>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IModelHandler<,>), typeof(IModelHandler<,>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IFileModelBuilder<>), typeof(IFileModelBuilder<>).Assembly);
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();
            return container;
        }
示例#24
0
        public static void Configure()
        {
            var container = new Container();

            container.RegisterPerWebRequest<ChanContext>();

            var cryptoProvider = new DefaultCryptoProvider("RnObFfS6tQKWfHJmwCC1yGLtl/1T3oP+FGMZOyr77us=", "JOgQUaVye+6qoThNrqZDjA==");
            container.RegisterSingleton(typeof(ICryptoProvider), () => cryptoProvider);

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
        public static void Configure()
        {
            var container = new Container();

            container.RegisterPerWebRequest<IDataContext>(() => new CmsContext());

            container.RegisterPerWebRequest<IReadStore, ReadStore>();

            container.RegisterPerWebRequest<IWriteStore, WriteStore>();

            container.Scan(typeof(CommandManager).Assembly);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
        internal static Container Initialize()
        {
            Container container = new Container();

            //container.Options.DefaultScopedLifestyle = new LifetimeScopeLifestyle();
            //container.Register<IUnitOfWork, UnitOfWork>(Lifestyle.Scoped);

            container.RegisterPerWebRequest<IUnitOfWork>(() => new UnitOfWork());

            container.RegisterPerWebRequest<IUserService, UserService>();

            //Registration registration = container.GetRegistration(typeof(IUnitOfWork)).Registration;

            //registration.SuppressDiagnosticWarning(DiagnosticType.DisposableTransientComponent, "OK");
            //#if DEBUG
            //            container.Verify();
            //#endif

            return container;
        }
        public static void Configure()
        {
            var container = new Container();

            container.RegisterPerWebRequest<MyDbContext>();

            container.RegisterPerWebRequest<UserManager>();

            container.RegisterPerWebRequest<RoleManager>();

            container.RegisterPerWebRequest<ClaimedActionsProvider>();

            container.Register<SignInManager>();

            container.RegisterPerWebRequest(() => HttpContext.Current.GetOwinContext().Authentication);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.RegisterMvcIntegratedFilterProvider();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
示例#28
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // IoC Container Setup
            var container = new Container();

            // Here comes container registrations
            #region Project-dependent injections
            container.RegisterPerWebRequest<IApplicationDbContext, ApplicationDbContext>();
            container.RegisterPerWebRequest<ApplicationDbContext>();

            container.RegisterPerWebRequest<IProductsService, ProductsService>();
            container.RegisterPerWebRequest<ICrudRepository<Product>, CrudRepository<Product>>();
            #endregion

            container.Verify();
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
示例#29
0
        public static Container Register()
        {
            // 1. Create a new Simple Injector container
            var container = new Container();

            container.RegisterPerWebRequest<DbContext, EntityDatabaseContext>();

            container.Register<IUnitOfWork, EntityFrameworkUnitOfWork>();
            container.RegisterOpenGeneric(typeof(IGenericRepository<>), typeof(EntityFrameworkGenericRepository<>));

            container.Register<IUserService, UserService>();

            return container;
        }
        public static Container GetInitializeContainer(
                  IAppBuilder app)
        {
            var container = new Container();
 
            container.RegisterSingleton(app);
 
            container.RegisterConditional(typeof(IRepository<>), typeof(Repository<>), c => !c.Handled);
 
            container.RegisterPerWebRequest<IDragonUserStore<AppMember>>(() =>
                new Dragon.SecurityServer.ChainedIdentity.Stores.UserStore<AppMember>(new List<IDragonUserStore<AppMember>>{
                    new UserStore<AppMember>(new Repository<AppMember>(), new Repository<IdentityUserClaim>(), new Repository<IdentityUserLogin>(), null, null)
                }));
 
            container.RegisterPerWebRequest(() => ApplicationUserManager.Create(container));

            container.RegisterPerWebRequest(() => container.GetOwinContext().Authentication);

            container.RegisterMvcControllers(
                    Assembly.GetExecutingAssembly());
            
            return container;
        }
示例#31
0
        /// <summary>
        ///   Loads the module into the kernel.
        /// </summary>
        public void RegisterComponents(SimpleInjector.Container container)
        {
            IConfiguration configuration = new Configuration();

            container.Register <IConfiguration>(() => configuration, Lifestyle.Singleton);

            Lazy <GallerySetting> gallerySetting = new Lazy <GallerySetting>(() =>
            {
                using (var entitiesContext = new EntitiesContext())
                {
                    var settingsRepo = new EntityRepository <GallerySetting>(entitiesContext);
                    return(settingsRepo.GetAll().FirstOrDefault());
                }
            });

            container.Register <GallerySetting>(() => gallerySetting.Value);
            //Bind<GallerySetting>().ToMethod(c => gallerySetting.Value);

            container.RegisterPerWebRequest <ISearchService, LuceneSearchService>();

            container.RegisterPerWebRequest <IEntitiesContext>(() => new EntitiesContext());
            container.RegisterPerWebRequest <IEntityRepository <User>, EntityRepository <User> >();
            container.RegisterPerWebRequest <IEntityRepository <PackageRegistration>, EntityRepository <PackageRegistration> >();
            container.RegisterPerWebRequest <IEntityRepository <Package>, EntityRepository <Package> >();
            container.RegisterPerWebRequest <IEntityRepository <PackageAuthor>, EntityRepository <PackageAuthor> >();
            container.RegisterPerWebRequest <IEntityRepository <PackageFramework>, EntityRepository <PackageFramework> >();
            container.RegisterPerWebRequest <IEntityRepository <PackageDependency>, EntityRepository <PackageDependency> >();
            container.RegisterPerWebRequest <IEntityRepository <PackageFile>, EntityRepository <PackageFile> >();
            container.RegisterPerWebRequest <IEntityRepository <PackageStatistics>, EntityRepository <PackageStatistics> >();
            container.RegisterPerWebRequest <IEntityRepository <PackageOwnerRequest>, EntityRepository <PackageOwnerRequest> >();

            container.RegisterPerWebRequest <IUserService, UserService>();
            container.RegisterPerWebRequest <IPackageService, PackageService>();
            container.RegisterPerWebRequest <ICryptographyService, CryptographyService>();

            container.Register <IFormsAuthenticationService, FormsAuthenticationService>(Lifestyle.Singleton);

            container.RegisterPerWebRequest <IControllerFactory, NuGetControllerFactory>();
            container.RegisterPerWebRequest <IIndexingService, LuceneIndexingService>();
            container.RegisterPerWebRequest <INuGetExeDownloaderService, NuGetExeDownloaderService>();

            Lazy <IMailSender> mailSenderThunk = new Lazy <IMailSender>(() =>
            {
                var settings = container.GetInstance <GallerySetting>();
                if (settings.UseSmtp)
                {
                    var mailSenderConfiguration = new MailSenderConfiguration()
                    {
                        DeliveryMethod = SmtpDeliveryMethod.Network,
                        Host           = settings.SmtpHost,
                        Port           = settings.SmtpPort,
                        EnableSsl      = configuration.SmtpEnableSsl,
                    };

                    if (!String.IsNullOrWhiteSpace(settings.SmtpUsername))
                    {
                        mailSenderConfiguration.UseDefaultCredentials = false;
                        mailSenderConfiguration.Credentials           = new NetworkCredential(
                            settings.SmtpUsername,
                            settings.SmtpPassword);
                    }

                    return(new NuGetGallery.MailSender(mailSenderConfiguration));
                }
                else
                {
                    var mailSenderConfiguration = new MailSenderConfiguration()
                    {
                        DeliveryMethod          = SmtpDeliveryMethod.SpecifiedPickupDirectory,
                        PickupDirectoryLocation = HostingEnvironment.MapPath("~/App_Data/Mail")
                    };

                    return(new NuGetGallery.MailSender(mailSenderConfiguration));
                }
            });

            container.Register <IMailSender>(() => mailSenderThunk.Value, Lifestyle.Singleton);

            container.Register <IMessageService, MessageService>(Lifestyle.Singleton);

            container.RegisterPerWebRequest <IPrincipal>(() => HttpContext.Current.User);
            //Bind<IPrincipal>().ToMethod(context => HttpContext.Current.User);

            switch (configuration.PackageStoreType)
            {
            case PackageStoreType.FileSystem:
            case PackageStoreType.NotSpecified:
                container.Register <IFileSystemService, FileSystemService>(Lifestyle.Singleton);
                container.Register <IFileStorageService, FileSystemFileStorageService>(Lifestyle.Singleton);
                break;

            case PackageStoreType.AzureStorageBlob:
                container.Register <ICloudBlobClient>(() => new CloudBlobClientWrapper(new CloudBlobClient(
                                                                                           new Uri(configuration.AzureStorageBlobUrl, UriKind.Absolute),
                                                                                           new StorageCredentialsAccountAndKey(configuration.AzureStorageAccountName, configuration.AzureStorageAccessKey)
                                                                                           ))
                                                      , Lifestyle.Singleton);
                container.Register <IFileStorageService, CloudBlobFileStorageService>(Lifestyle.Singleton);
                break;

            case PackageStoreType.AmazonS3Storage:
                container.Register <IAmazonS3Client, AmazonS3ClientWrapper>(Lifestyle.Singleton);
                container.Register <IFileStorageService, AmazonS3FileStorageService>(Lifestyle.Singleton);
                break;
            }

            container.Register <IPackageFileService, PackageFileService>(Lifestyle.Singleton);
            container.Register <IUploadFileService, UploadFileService>();

            // todo: bind all package curators by convention
            container.Register <IAutomaticPackageCurator, WebMatrixPackageCurator>(Lifestyle.Singleton);
            container.Register <IAutomaticPackageCurator, Windows8PackageCurator>(Lifestyle.Singleton);

            // todo: bind all commands by convention
            container.RegisterPerWebRequest <IAutomaticallyCuratePackageCommand, AutomaticallyCuratePackageCommand>();
            container.RegisterPerWebRequest <ICreateCuratedPackageCommand, CreateCuratedPackageCommand>();
            container.RegisterPerWebRequest <IDeleteCuratedPackageCommand, DeleteCuratedPackageCommand>();
            container.RegisterPerWebRequest <IModifyCuratedPackageCommand, ModifyCuratedPackageCommand>();

            // todo: bind all queries by convention
            container.RegisterPerWebRequest <ICuratedFeedByKeyQuery, CuratedFeedByKeyQuery>();
            container.RegisterPerWebRequest <ICuratedFeedByNameQuery, CuratedFeedByNameQuery>();
            container.RegisterPerWebRequest <ICuratedFeedsByManagerQuery, CuratedFeedsByManagerQuery>();
            container.RegisterPerWebRequest <IPackageRegistrationByKeyQuery, PackageRegistrationByKeyQuery>();
            container.RegisterPerWebRequest <IPackageRegistrationByIdQuery, PackageRegistrationByIdQuery>();
            container.RegisterPerWebRequest <IUserByUsernameQuery, UserByUsernameQuery>();
            container.RegisterPerWebRequest <IPackageIdsQuery, PackageIdsQuery>();
            container.RegisterPerWebRequest <IPackageVersionsQuery, PackageVersionsQuery>();

            container.RegisterPerWebRequest <IAggregateStatsService, AggregateStatsService>();

            RegisterChocolateySpecific(container);
        }
示例#32
0
 private void RegisterChocolateySpecific(SimpleInjector.Container container)
 {
     container.RegisterPerWebRequest <IUserSiteProfilesService, UserSiteProfilesService>();
     container.RegisterPerWebRequest <IEntityRepository <UserSiteProfile>, EntityRepository <UserSiteProfile> >();
 }