Represents a configuration parameter.
コード例 #1
0
        protected override void Init()
        {
            ComponentRegistration <object> component = Component.For(typeof(IRepository <>)).ImplementedBy(typeof(NHRepository <>));

            if (!string.IsNullOrEmpty(config.RepositoryKey))
            {
                component.Named(config.RepositoryKey);
            }

            Kernel.Register(component);
            ComponentRegistration <IUnitOfWorkFactory> registerFactory =
                Component.For <IUnitOfWorkFactory>()
                .ImplementedBy <NHibernateUnitOfWorkFactory>();

            registerFactory.Parameters(ComponentParameter.ForKey("configurationFileName").Eq(config.NHibernateConfigurationFile));

            // if we are running in test mode, we don't want to register
            // the assemblies directly, we let the DatabaseTestFixtureBase do it
            // this allow us to share the configuration between the test & prod projects
            if (DatabaseTestFixtureBase.IsRunningInTestMode == false)
            {
                registerFactory.DependsOn(Property.ForKey("assemblies").Eq(Assemblies));
            }
            Kernel.Register(registerFactory);

            Kernel.AddComponentInstance("entitiesToRepositories", typeof(INHibernateInitializationAware),
                                        new EntitiesToRepositoriesInitializationAware(config.IsCandidateForRepository));
        }
コード例 #2
0
 public ServicesDependencyResolver(DirectoryInfo dropDirectory) : base(null)
 {
     innerContainer.Register(
         Component.For <ISiteStructureBuilder>()
         .ImplementedBy <SiteStructureBuilder>()
         .Parameters(Parameter.ForKey("dropDirectoryPath").Eq(dropDirectory.FullName))
         .LifeStyle.Transient
         );
 }
コード例 #3
0
		private void Apply(ComponentModel model, Parameter parameter)
		{
			if (parameter.Value != null)
			{
				AddParameter(model, parameter.Key, parameter.Value);
			}
			else if (parameter.ConfigNode != null)
			{
				AddParameter(model, parameter.Key, parameter.ConfigNode);
			}
		}
コード例 #4
0
        public void TestAutoFactory()
        {
            var container = new WindsorContainer();

            #region spoiler
            container.AddFacility<TypedFactoryFacility>();
            container.Register(
                Component.For<IServiceAutoFactory>().AsFactory(),
                Component.For<DataAccess>(),
                Component.For<Service>()
                );
            #endregion

            var factory = container.Resolve<IServiceAutoFactory>();

            var context = new Parameter();
            var dep = factory.Create(context);

            dep.Parameter.Should().BeSameAs(context);
            dep.DataAccess.Should().NotBeNull();
        }
コード例 #5
0
        public WindsorDependencyResolver(ICommandArgs commandArgs)
        {
            innerContainer = new WindsorContainer();

            if (commandArgs != null)
            {
                innerContainer.Kernel.AddComponentInstance <ICommandArgs>(typeof(ICommandArgs), commandArgs);
            }

            innerContainer.Kernel.Resolver.AddSubResolver(new EnumerableResolver(innerContainer.Kernel));

            innerContainer.Register(
                Component.For <IBuildConfigReader>()
                .Named("boo")
                .ImplementedBy <BooBuildConfigReader>()
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <SVNSourceControl>()
                .Named("Svn")
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <GitSourceControl>()
                .Named("Git")
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <MercurialSourceControl>()
                .Named("Hg")
                .LifeStyle.Transient
                );


            innerContainer.Register(
                Component.For <IPackageCommand>()
                .Named("install")
                .ImplementedBy <PackageBuilder>()
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <IGet>()
                .Named("get")
                .ImplementedBy <Get>()
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <IFileSystemProvider>()
                .Named("filesystemprovider")
                .ImplementedBy <FileSystemProvider>()
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <IProcessFactory>()
                .Named("processfactory")
                .ImplementedBy <DiagnosticsProcessFactory>()
                .LifeStyle.Transient

                );

            innerContainer.Register(
                Component.For <SourceControl>()
                .ImplementedBy <GitSourceControl>()
                .Parameters(Parameter.ForKey("url").Eq(MetaDataSynchroniser.PackageTreeUri))
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <IMetaDataSynchroniser>()
                .ImplementedBy <MetaDataSynchroniser>()
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <IPackageTree>()
                .ImplementedBy <PackageTree>()
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <IEnvironmentVariable>()
                .ImplementedBy <EnvironmentVariable>()
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <IShellRunner>()
                .ImplementedBy <CommandLineRunner>()
                .LifeStyle.Transient
                );

            innerContainer.Register(
                Component.For <IDependencyDispatcher>()
                .ImplementedBy <DependencyDispatcher>()
                .LifeStyle.Transient,

                Component.For <IDependentUpdaterExecutor>()
                .ImplementedBy <DependentUpdaterExecutor>()
                .LifeStyle.Transient,

                AllTypes.Of <IDependentUpdater>().FromAssembly(Assembly.GetExecutingAssembly())
                .WithService.FirstInterface().Configure(config => config.LifeStyle.Transient)
                );
        }