Beispiel #1
0
        private void InitializeWindsor(IWindsorContainer container)
        {
            container.Register(Component.For <IWindsorContainer, WindsorContainer>().Instance(container));
            container.Register(
                Classes.FromAssemblyInDirectory(new AssemblyFilter(new FileInfo(new System.Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath).Directory.ToString()))
                .BasedOn <ISnooper>().WithServiceFromInterface(typeof(ISnooper)).WithServiceSelf().LifestyleTransient(),
                Component.For <Func <IWindsorContainer, Guid, string, NetfoxAPIFacade> >().Instance((c, id, path) => new NetfoxAPIFacade(c, id, path)).LifestyleSingleton(),

                /* DAL */
                Component.For <Func <NetfoxWebDbContext> >().Instance(() => new NetfoxWebDbContext()).LifestyleSingleton(),
                Component.For <IUnitOfWorkProvider>().ImplementedBy <EntityFrameworkUnitOfWorkProvider <NetfoxWebDbContext> >().LifestyleSingleton(),
                Component.For <IUnitOfWorkRegistry>().UsingFactoryMethod(p => new AsyncLocalUnitOfWorkRegistry()).LifestyleSingleton(),
                Classes.FromAssemblyContaining <BusinessLayer>().BasedOn(typeof(AppQueryBase <>)).LifestyleTransient(),
                Classes.FromAssemblyContaining <BusinessLayer>().BasedOn(typeof(AppFirstLevelQueryBase <>)).LifestyleTransient(),
                Classes.FromAssemblyContaining <BusinessLayer>().BasedOn(typeof(IRepository <,>)).WithServiceAllInterfaces().WithServiceSelf().LifestyleTransient(),
                Component.For(typeof(IRepository <,>)).ImplementedBy(typeof(EntityFrameworkRepository <,>)).IsFallback().LifestyleTransient(),
                Component.For <IDateTimeProvider>().Instance(new UtcDateTimeProvider()),
                Component.For(typeof(IEntityDTOMapper <,>)).ImplementedBy(typeof(EntityDTOMapper <,>)).LifestyleSingleton(),
                /* // DAL */

                /* BL */
                Classes.FromAssemblyContaining <BusinessLayer>().BasedOn <FacadeBase>().LifestyleTransient(),
                Classes.FromAssemblyContaining <BusinessLayer>().BasedOn <IFilterDTO>().LifestyleTransient(),
                Classes.FromAssemblyContaining <BusinessLayer>().BasedOn <NetfoxFacadeBase>().LifestyleTransient());

            var netfoxFrameworkApiWindsorInstaller = new NetfoxFrameworkApiWindsorInstaller();

            netfoxFrameworkApiWindsorInstaller.Install(container, null);
        }
Beispiel #2
0
        /// <summary> Tests start.</summary>
        public virtual void SetUpSQL()
        {
            this.SetUp();
            var netfoxFrameworkApiWindsorInstaller = new NetfoxFrameworkApiWindsorInstaller();

            netfoxFrameworkApiWindsorInstaller.SetUpSQL(this.WindsorContainer);
        }
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            var sqlConnectionStringBuilder = new SqlConnectionStringBuilder(NetfoxWebSettings.Default.ConnectionString)
            {
                InitialCatalog = NetfoxWebSettings.Default.InvestigationPrefix
            };

            container.Register(
                Component.For <Func <IWindsorContainer, SqlConnectionStringBuilder, NetfoxDbContext> >()
                .Instance((windsorContainer, sqlBuilder) => new NetfoxDbContext(windsorContainer, sqlBuilder))
                .LifestyleSingleton(),

                Classes.FromAssemblyContaining <BusinessLayer>()
                .BasedOn <INetfoxProvider>()
                .LifestyleSingleton(),

                Classes.FromAssemblyContaining <BusinessLayer>()
                .BasedOn <HangfireFacade>()
                .LifestyleTransient(),

                Component.For <SqlConnectionStringBuilder>()
                .Instance(sqlConnectionStringBuilder).IsDefault(),

                Classes.FromAssemblyInDirectory(new AssemblyFilter(new FileInfo(new System.Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath).Directory.ToString()))
                .BasedOn(typeof(NetfoxQueryBase <>))
                .LifestyleTransient(),

                Component.For <IObservableNetfoxDBContext>()
                .ImplementedBy <NetfoxDbContext>()
                .Named(nameof(IObservableNetfoxDBContext))
                .IsDefault()
                .LifestyleSingleton(),

                Classes.FromAssemblyInDirectory(new AssemblyFilter(new FileInfo(new System.Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath).Directory.ToString()))
                .BasedOn <ISnooperWeb>()
                .WithServiceFromInterface(typeof(ISnooperWeb))
                .WithServiceSelf().LifestyleTransient(),

                Classes.FromAssemblyInDirectory(new AssemblyFilter(new FileInfo(new System.Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath).Directory.ToString()))
                .BasedOn <ISnooper>()
                .WithServiceFromInterface(typeof(ISnooper))
                .WithServiceSelf()
                .LifestyleTransient()
                );

            var netfoxFrameworkApiWindsorInstaller = new NetfoxFrameworkApiWindsorInstaller();

            netfoxFrameworkApiWindsorInstaller.Install(container, null);

            var observableNetfoxDBContext = container.Resolve <IObservableNetfoxDBContext>();

            observableNetfoxDBContext.RegisterVirtualizingObservableDBSetPagedCollections();
        }