本文整理汇总了C#中WindsorContainer.ResolveAll方法的典型用法代码示例。如果您正苦于以下问题:C# WindsorContainer.ResolveAll方法的具体用法?C# WindsorContainer.ResolveAll怎么用?C# WindsorContainer.ResolveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindsorContainer
的用法示例。
在下文中一共展示了WindsorContainer.ResolveAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var bits = Environment.Is64BitProcess ? "64 bit" : "32 bit";
Console.WriteLine($"Running {bits} process");
//using windsor for convenience
using (var container = new WindsorContainer())
{
container.Register(Classes.FromAssemblyInDirectory(new AssemblyFilter("."))
.BasedOn<ISerializer>()
.OrBasedOn(typeof(ISerializerStream))
.WithServiceAllInterfaces()
.LifestyleTransient());
container.Register(Classes.FromAssemblyInDirectory(new AssemblyFilter("."))
.BasedOn<IStreamTest>()
.OrBasedOn(typeof(ITest))
.WithServiceAllInterfaces()
.LifestyleSingleton());
var allSerializers = container.ResolveAll<ISerializer>();
var allSerializerStreams = container.ResolveAll<ISerializerStream>();
var allStreamTests = container.ResolveAll<IStreamTest>();
var testExecutor = new TestExecutor();
foreach (var serializerStream in allSerializerStreams)
foreach (var streamTest in allStreamTests)
testExecutor.ExecuteLargePropertyTest(streamTest, serializerStream);
}
}
示例2: LoadPatches
protected virtual void LoadPatches() {
patches = new List<IMvcPatch>();
var patchIocFile = TargetFileSystem.ReadXml("ioc/patches.config", null,
new ReadXmlOptions{Merge = true});
if (patchIocFile == null){
patchIocFile = "<configuration />";
}
try{
var patchIocResource = new StaticContentResource(patchIocFile);
if (null != patchIocFile){
var container = new WindsorContainer(new XmlInterpreter(patchIocResource));
try{
foreach (var patch in container.ResolveAll<IMvcPatch>()){
patch.FileSystem = FileSystem;
patch.Manager = this;
patch.Identity = new SimplePackageIdentity(patch.Code);
patches.Add(patch);
}
}
finally{
container.Dispose();
}
}
}catch(Exception ex){
throw new Exception("error in config:\r\n"+patchIocFile,ex);
}
}
示例3: CanInstallHandlersInTheContainer
public void CanInstallHandlersInTheContainer()
{
using (IWindsorContainer container = new WindsorContainer())
{
//This line just forces the domain events lib to be loaded, and handlers available in the app domain.
IProcessEvents proc = new DailyActivityEventProcessor(new Mock<IRepository<DailyActivity>>().Object);
container.Install(new HandlerInstaller(), new RepositoryInstaller());
ProcessStarted started = new ProcessStarted(Guid.NewGuid(), Guid.NewGuid());
var handlerType = typeof (IHandleEvent<>).MakeGenericType(started.GetType());
IEnumerable<dynamic> handlers = container.ResolveAll(handlerType).Cast<dynamic>();
Assert.IsNotNull(handlers);
Assert.AreEqual(2, handlers.Count());
var handler = handlers.FirstOrDefault(o => o.GetType() == typeof (DailyActivityEventProcessor));
Assert.IsNotNull(handler);
}
}
示例4: Main
static void Main(string[] args)
{
IWindsorContainer container = new WindsorContainer();
BuildDependencies(container);
var commanLineReaders = container.ResolveAll<ICommandLineReader>().ToList();
bool exit = false;
while (!exit)
{
var command = Console.ReadLine();
if (command == "exit" || command == "quit")
{
exit = true;
continue;
}
foreach (var commandReader in commanLineReaders)
{
commandReader.Process(command);
break;
}
}
}
示例5: InstallAssemblies
/// <summary>
/// Installs the assemblies.
/// </summary>
/// <param name = "container">The container.</param>
/// <param name = "assemblies">The assemblies.</param>
public static void InstallAssemblies(this IIoCContainer container, Assembly[] assemblies)
{
//Contract.Requires(container != null);
//Contract.Requires(assemblies != null);
using (var registrationContainer = new WindsorContainer())
{
foreach (var assembly in assemblies)
{
try
{
//container.Install(FromAssembly.Instance(assembly));
registrationContainer.Register(AllTypes.FromAssembly(assembly)
.IncludeNonPublicTypes()
.BasedOnAsService<IComponentInstaller>()
.Configure(c => c.LifeStyle.Transient));
}
catch (Exception e)
{
var msg = String.Format("Could not load assembly '{0}' because related assembly can't be loaded. Exception details: {1}", assembly.FullName, e.Message);
_logger.Fatal(msg, e);
throw new Exception(msg);
}
}
foreach (var item in registrationContainer.ResolveAll<IComponentInstaller>())
item.Install(container, assemblies);
}
}
示例6: Main
static void Main(string[] args) {
//Load IoC container
var container = new WindsorContainer();
// Grab all IoC installers in Bin dir
container.Install(
FromAssembly.InDirectory(new AssemblyFilter(Environment.CurrentDirectory))
);
// Resolve all filters and order according to the order property
var filters = container.ResolveAll<IFilter>().OrderBy(f => f.Order);
// Resolve the registered pipeline implementation
var pipeline = container.Resolve<IPipeline>();
//Load and execute pipeline
Console.WriteLine("Pipeline starting");
foreach(var filter in filters) {
pipeline.Register(filter);
}
pipeline.Execute(args[0]);
Console.WriteLine("Pipeline completed");
}
示例7: PluginsCanBeResolvedFromWindsor
public void PluginsCanBeResolvedFromWindsor()
{
IWindsorContainer container = new WindsorContainer();
InitializeWindsor(ref container);
var cnt = container.ResolveAll<IPlugin>().Count(item => item != null);//count of somehow initialized plugins
Assert.AreNotEqual(cnt,0,"Windsor container could not plugins have resolved");
}
示例8: ContainerIsBeingDesposedProperly
public void ContainerIsBeingDesposedProperly()
{
IWindsorContainer container = new WindsorContainer();
InitializeWindsor(ref container);
ILmsService service = container.Resolve<ILmsService>();
container.Dispose();
Assert.That(container.ResolveAll<Object>().Count(item => item != null) == 0);
}
示例9: CanResolveMoreThanSingleComponentForService
public void CanResolveMoreThanSingleComponentForService()
{
IWindsorContainer container = new WindsorContainer()
.AddComponent<IClock, IsraelClock>()
.AddComponent<IClock, WorldClock>();
IClock[] clocks = container.ResolveAll<IClock>();
Assert.AreEqual(2, clocks.Length);
}
示例10: OnStart
protected override void OnStart(string[] args)
{
var wc = new WindsorContainer();
ServiceConfigurator.Begin(wc)
.FinishConfiguration();
_container = wc;
foreach (IStartableService s in _container.ResolveAll<IStartableService>())
{
s.Start();
}
}
示例11: CanGetAllValidators
public void CanGetAllValidators()
{
WindsorContainer container = new WindsorContainer();
container.Register(AllTypes.FromAssembly(typeof(IValidator).Assembly).Pick()
.WithService.DefaultInterface());
var validators = container.ResolveAll<IValidator>();
Assert.IsNotNull(validators);
Assert.AreEqual(3, validators.Count());
}
示例12: CanUseMutliResolveWithGenericSpecialization
public void CanUseMutliResolveWithGenericSpecialization()
{
IWindsorContainer container = new WindsorContainer()
.AddComponent("demo", typeof (IRepository<>), typeof (DemoRepository<>))
.AddComponent("trans", typeof(IRepository<>), typeof(TransientRepository<>));
IRepository<IClock> resolve = container.Resolve<IRepository<IClock>>();
Assert.IsNotNull(resolve);
IRepository<IsraelClock>[] repositories = container.ResolveAll<IRepository<IsraelClock>>();
Assert.AreEqual(2, repositories.Length);
}
示例13: TryLoadCorrectPlugin
public void TryLoadCorrectPlugin()
{
IWindsorContainer container=new WindsorContainer();
InitializeWindsor(ref container);
var plugins = container.ResolveAll<IPlugin>();
foreach (var plugin in plugins)
{
Assert.IsNotNull(plugin.BuildActions(),plugin.GetName());
Assert.IsNotNull(plugin.BuildMenuItems(), plugin.GetName());
}
Assert.Pass("Every plugin can be accessed");
}
示例14: TestXml
public void TestXml()
{
var container = new WindsorContainer();
container.Kernel.ComponentModelCreated += model => {
if (model.Name == "MainClass2")
model.Constructors.Remove(model.Constructors.First(c => c.Dependencies.Any(m => m.TargetType == typeof(IMyInterface))));
};
container.Install(Configuration.FromXml(new StaticContentResource(xmlConfig)));
var objs = container.ResolveAll<IMyWindsorInterface>();
Assert.AreEqual(1, objs.Count(o => o.Dep == null));
Assert.AreEqual(1, objs.Count(o => o.Dep != null));
}
示例15: Bug
public void Bug()
{
var container = new WindsorContainer();
container.AddFacility<FactorySupportFacility>();
container.Register(Component.For<IService>
().ImplementedBy<Service1>().Named("1"));
container.Register(Component.For<IService>
().ImplementedBy<Service2>().Named("2"));
container.Register(Component.For<IEnumerable<IService>>
().UsingFactoryMethod(() => container.ResolveAll<IService>()));
container.Register(Component.For<Consumer>());
Assert.IsNotNull(container.Kernel.Resolve<Consumer>());
}