本文整理汇总了C#中IWindsorContainer.AddComponentLifeStyle方法的典型用法代码示例。如果您正苦于以下问题:C# IWindsorContainer.AddComponentLifeStyle方法的具体用法?C# IWindsorContainer.AddComponentLifeStyle怎么用?C# IWindsorContainer.AddComponentLifeStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWindsorContainer
的用法示例。
在下文中一共展示了IWindsorContainer.AddComponentLifeStyle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public void Register(IWindsorContainer container)
{
Assembly.GetAssembly(typeof(ControllersRegistrarMarker)).GetExportedTypes()
.Where(IsController)
.Each(type => container.AddComponentLifeStyle(
type.Name.ToLower(),
type,
LifestyleType.Transient));
}
示例2: RegisterControllersInContainer
// Dies nur als Beispiel, besser direkt die Implementierung von http://mvccontrib.org verwenden
private static void RegisterControllersInContainer(IWindsorContainer container)
{
var controllerType = from t in typeof(HomeController).Assembly.GetTypes()
where typeof (IController).IsAssignableFrom(t)
select t;
foreach (var type in controllerType)
{
container.AddComponentLifeStyle(type.FullName, type, LifestyleType.Transient);
}
}
示例3: RegisterTypesInContainer
private static void RegisterTypesInContainer(IWindsorContainer container)
{
RegisterControllersInContainer(container);
container.AddComponentLifeStyle<ICustomerRepository, CustomerRepository>(LifestyleType.Transient);
container.AddComponentLifeStyle<IOrderRepository, OrderRepository>(LifestyleType.Transient);
container.AddComponentLifeStyle<ICustomerService, CustomerService>(LifestyleType.Transient);
container.AddComponentLifeStyle<IOrderService, OrderService>(LifestyleType.Transient);
container.AddComponentLifeStyle<ICustomerMapper, CustomerMapper>(LifestyleType.Singleton);
container.AddComponentLifeStyle<IOrderMapper, OrderMapper>(LifestyleType.Singleton);
}
示例4: WindsorControllerFactory
// The constructor:
// 1. Sets up a new IoC container
// 2. Registers all components specified in web.config
// 3. Registers all controller types as components
public WindsorControllerFactory()
{
// Instantiate a container, taking configuration from web.config
container = WindsorContainerProvider.Instance();
// Also register all the controller types as transient
var controllerTypes =
from t in Assembly.GetExecutingAssembly().GetTypes()
where typeof(IController).IsAssignableFrom(t)
select t;
foreach (Type t in controllerTypes)
{
container.AddComponentLifeStyle(t.FullName, t, LifestyleType.Transient);
}
}
示例5: Configure
public static void Configure(IWindsorContainer container)
{
//allows us to take a dependency on arrays
container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
//
container.AddComponent<Dispatcher>("dispatcher");
//argument parsing
container.AddComponentLifeStyle<IArgumentParser, ArgumentParser>("argumentParser", LifestyleType.Transient);
container.AddComponentLifeStyle<IArgumentMapFactory, ArgumentMapFactory>("argumentMapFactory", LifestyleType.Transient);
//helper shims
container.AddComponentLifeStyle<IConsole, ConsoleHelper>("consoleHelper", LifestyleType.Transient);
container.AddComponentLifeStyle<IPath, PathAdapter>("pathAdapter", LifestyleType.Transient);
container.AddComponentLifeStyle<IFileSystem, FileSystem>("fileSystem", LifestyleType.Transient);
//templating
container.AddComponentLifeStyle<ITemplateProcessor, NVelocityTemplateProcessor>("templateProcessor",
LifestyleType.Transient);
//package repository
container.AddComponent<IPackageRepository, LocalPackageRepository>("package.repository");
//project stuff
container.AddComponentLifeStyle<IProjectManifestStore, XmlProjectManifestStore>("xmlProjectStore", LifestyleType.Transient);
container.AddComponentLifeStyle<IProjectManifestRepository, ProjectManifestRepository>("projectManifestRepository", LifestyleType.Transient);
//default package commands
container.AddComponent<ICommand, HelpCommand>("help");
container.Register(
Component.For<ICommand>().ImplementedBy<NewProjectCommand>()
.Named("project")
.Parameters(
Parameter.ForKey("rootTemplateDirectory").Eq("a"), //TODO: correct this
Parameter.ForKey("defaultTemplate").Eq("b"))); //TODO: Correct this
SetupNewProject(container);
container.AddComponent<ICommand, ListCommand>("list");
container.AddComponent<ICommand, InstallCommand>("install");
}
示例6: Application_Start
protected void Application_Start(object sender, EventArgs e)
{
XmlConfigurator.ConfigureAndWatch(new FileInfo(Server.MapPath("/log4net.config")));
GlobalLog = LogManager.GetLogger(typeof (Global));
GlobalLog.Debug("Application_Start");
container = new WindsorContainer();
container.AddComponentLifeStyle<Service>(LifestyleType.Transient);
container.AddFacility<FactorySupportFacility>();
container.Register(Component.For<IHttpModule>()
.ImplementedBy<UserHttpModule>()
.LifeStyle.Custom<PerHttpApplicationLifestyleManager>());
container.Register(Component.For<IHttpModule>()
.ImplementedBy<UserHttpModule2>()
.LifeStyle.Custom<PerHttpApplicationLifestyleManager>());
container.Register(Component.For<HttpRequestBase>()
.LifeStyle.PerWebRequest
.UsingFactoryMethod(() => new HttpRequestWrapper(HttpContext.Current.Request)));
container.Register(Component.For<HttpContextBase>()
.LifeStyle.PerWebRequest
.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));
}
示例7: SetupNewProject
private static void SetupNewProject(IWindsorContainer container)
{
container.AddComponentLifeStyle<ITransformationElement,FolderTransformationElement>("folderTransformation",
LifestyleType.Transient);
container.AddComponentLifeStyle<ITransformationElement,FileTransformationElement>("fileTransformation", LifestyleType.Transient);
container.AddComponentLifeStyle<IProjectTransformationPipeline,ProjectTransformationPipeline>("transformationPipeline", LifestyleType.Transient);
}
示例8: Install
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.AddComponentLifeStyle<TwitterContext>(LifestyleType.Singleton);
}
示例9: RegisterComponents
public void RegisterComponents(IWindsorContainer container)
{
container.AddComponentLifeStyle("newscontroller", typeof(NewsController), LifestyleType.Transient);
container.AddComponent("News", typeof(Tags.News));
}
示例10: RegisterRepositories
private static void RegisterRepositories(IWindsorContainer container)
{
IEnumerable<Type> repositories = Assembly.GetExecutingAssembly().
GetTypes().Where(IsRepository);
foreach (Type repository in repositories)
{
container.AddComponentLifeStyle(repository.Name, repository,
LifestyleType.Transient);
}
}
示例11: RegisterGateways
private static void RegisterGateways(IWindsorContainer container)
{
container.AddComponentLifeStyle("bloggerGateway",
typeof(BloggerGateway), LifestyleType.Transient);
}