本文整理汇总了C#中WindsorContainer.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# WindsorContainer.Dispose方法的具体用法?C# WindsorContainer.Dispose怎么用?C# WindsorContainer.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindsorContainer
的用法示例。
在下文中一共展示了WindsorContainer.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
var container = new WindsorContainer();
container.Install(FromAssembly.This());
var client = container.Resolve<IQuilt4NetClient>();
client.WebApiClient.WebApiRequestEvent += WebApiClientWebApiRequestEvent;
client.WebApiClient.WebApiResponseEvent += WebApiClient_WebApiResponseEvent;
client.WebApiClient.AuthorizationChangedEvent += WebApiClient_AuthorizationChangedEvent;
var business1 = container.Resolve<ISomeBusiness1>();
var business2 = container.Resolve<ISomeBusiness2>();
try
{
business1.Execute();
business2.Execute();
}
catch (Exception exception)
{
Console.WriteLine("Exception: " + exception.Message);
}
//business1.Dispose();
container.Dispose();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
示例2: Main
static void Main()
{
var container = new WindsorContainer()
.Register(Component.For<IHandleMessages<GetGreetingReply>>()
.ImplementedBy<GetGreetingReplyHandler>()
.LifestyleTransient());
var bus = Configure.With(new CastleWindsorContainerAdapter(container))
.Logging(l => l.None()) // disable logging to avoid polluting the console
.Transport(t => t.UseMsmq("IntegrationSample.Client.input"))
.Routing(d => d.TypeBased().MapAssemblyOf<GetGreetingRequest>("IntegrationSample.IntegrationService.input"))
.Start();
Console.WriteLine("Press R to request a greeting and Q to quit...");
var keepRunning = true;
do
{
var key = Console.ReadKey(true);
switch (char.ToLower(key.KeyChar))
{
case 'r':
bus.Send(new GetGreetingRequest()).Wait();
break;
case 'q':
keepRunning = false;
break;
}
} while (keepRunning);
container.Dispose();
}
示例3: 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);
}
}
示例4: Main
static void Main()
{
var container = new WindsorContainer()
.Register(Component.For<IHandleMessages<GetGreetingReply>>()
.ImplementedBy<GetGreetingReplyHandler>()
.LifestyleTransient());
var bus = Configure.With(new WindsorContainerAdapter(container))
.Logging(l => l.None()) // disable logging to avoid polluting the console
.Transport(t => t.UseMsmqAndGetInputQueueNameFromAppConfig())
.MessageOwnership(d => d.FromRebusConfigurationSection())
.CreateBus().Start();
Console.WriteLine("Press R to request a greeting and Q to quit...");
var keepRunning = true;
do
{
var key = Console.ReadKey(true);
switch (char.ToLower(key.KeyChar))
{
case 'r':
bus.Send(new GetGreetingRequest());
break;
case 'q':
keepRunning = false;
break;
}
} while (keepRunning);
container.Dispose();
}
示例5: Main
static void Main(string[] args)
{
var container = new WindsorContainer();
container.Install(FromAssembly.This());
bool logToNewRelic = args.Length > 1 && args[1].ToLower() == "newrelic";
if (logToNewRelic)
{
container.Register(Component.For<ILogStatisticsRepository>()
.ImplementedBy<NewRelicLogStatisticsRepository>()
.IsDefault()
.Named("WriteToNewRelic")
.LifestyleTransient());
}
else
{
container.Register(Component.For<ILogStatisticsRepository>()
.ImplementedBy<FileLogStatisticsRepository>()
.IsDefault()
.Named("WriteToFile")
.LifestyleTransient());
}
var startProgram = container.Resolve<StartProgram>();
startProgram.Start(args);
container.Dispose();
}
示例6: Main
static void Main(string[] args)
{
_containerClient = new WindsorContainer(new XmlInterpreter("config_client.config"));
_containerServer = new WindsorContainer(new XmlInterpreter("config_server.config"));
_containerServer.Register(Component.For<IRemoteServ1>().ImplementedBy<RemoteServImpl>());
_containerClient.Register(Component.For<IRemoteServ1>());
try
{
var service = _containerClient.Resolve<IRemoteServ1>();
InvokeBatch(service);
}
finally
{
Console.WriteLine("Disposing client");
_containerClient.Dispose();
Console.WriteLine("Disposing server");
_containerServer.Dispose();
Console.WriteLine("Disposed");
}
}
示例7: button1_Click
private void button1_Click(object sender, EventArgs e)
{
IWindsorContainer container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));
IJobRunMgr jobRunMgr = container.Resolve<IJobRunMgr>("JobRunMgr.service");
jobRunMgr.RunBatchJobs(container);
container.Dispose();
}
示例8: Main
public static void Main(string[] args)
{
var container = new WindsorContainer();
container.Register (
Component.For<ManagerService>()
.LifeStyle.Singleton);
container.Register (
Component.For<UnmanagedService>()
.Interceptors<ManagerService>());
var managerService = container.Resolve<ManagerService>();
managerService.Start ();
var unmanagedSvc = container.Resolve<UnmanagedService>();
unmanagedSvc.Start ();
Console.WriteLine ("Press enter to stop the service");
Console.ReadLine ();
managerService.Stop ();
unmanagedSvc.Stop ();
container.Dispose ();
}
示例9: Main
static void Main(string[] args)
{
var container = new WindsorContainer(new XmlInterpreter()).Install(FromAssembly.This());
container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
HostFactory.Run(r =>
{
r.Service<IScheduleLimIntegration>(s =>
{
s.ConstructUsing(name => new ScheduleWorker(container));
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc =>
{
tc.End();
container.Release(tc);
container.Dispose();
});
});
r.RunAsLocalSystem();
r.SetDescription(System.Configuration.ConfigurationManager.AppSettings["service/config/description"]);
r.SetDisplayName(System.Configuration.ConfigurationManager.AppSettings["service/config/displayName"]);
r.SetServiceName(System.Configuration.ConfigurationManager.AppSettings["service/config/name"]);
});
}
示例10: Main
static void Main(string[] args)
{
var container = new WindsorContainer(new XmlInterpreter()).Install(FromAssembly.This());
container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
HostFactory.Run(x =>
{
x.Service<ICacheWorker>(s =>
{
s.ConstructUsing(name => new CacheWorker(container));
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc =>
{
tc.End();
container.Release(tc);
container.Dispose();
});
});
x.RunAsLocalSystem();
x.SetDescription(CachingConfiguration.ServiceDescription);
x.SetDisplayName(CachingConfiguration.ServiceDisplayName);
x.SetServiceName(CachingConfiguration.ServiceName);
});
}
示例11: ResolvingPooledComponentSample
public void ResolvingPooledComponentSample()
{
IWindsorContainer container = new WindsorContainer();
container.Register(
Component.For<IRepository<Client>>().ImplementedBy<ClientRepository>().LifeStyle.PooledWithSize(2, 4));
// Two instances will be created when the component is first requested
var instanceA = container.Resolve<IRepository<Client>>();
var instanceB = container.Resolve<IRepository<Client>>();
// The two instances will be marked as 'not in use' and will be available for subsequent requests
container.Release(instanceA);
container.Release(instanceB);
// Same two instances will be returned
var instanceC = container.Resolve<IRepository<Client>>();
var instanceD = container.Resolve<IRepository<Client>>();
// Two more instances will be created and added to the pool
var instanceE = container.Resolve<IRepository<Client>>();
var instanceF = container.Resolve<IRepository<Client>>();
container.Dispose();
}
示例12: ResolvingPerThreadComponents_NewInstanceIsCreatedForEachThread
public void ResolvingPerThreadComponents_NewInstanceIsCreatedForEachThread()
{
IWindsorContainer container = new WindsorContainer();
container.Register(
Component.For<IRepository<Client>>().ImplementedBy<ClientRepository>().LifeStyle.PerThread);
Task firstTask = Task.Factory.StartNew(() =>
{
var repository = container.Resolve<IRepository<Client>>();
var secondRepository = container.Resolve<IRepository<Client>>();
Assert.AreSame(repository, secondRepository);
});
Task secondTask = Task.Factory.StartNew(() =>
{
var repository = container.Resolve<IRepository<Client>>();
var secondRepository = container.Resolve<IRepository<Client>>();
Assert.AreSame(repository, secondRepository);
});
Task.WaitAll(firstTask, secondTask);
container.Dispose();
}
示例13: DoTest
public override TestResult DoTest(ITestCase testCase, int testCasesNumber, bool singleton)
{
var result = new TestResult { Singleton = singleton, TestCasesNumber = testCasesNumber };
var sw = new Stopwatch();
var c = new WindsorContainer();
if (singleton)
{
sw.Start();
c = (WindsorContainer)testCase.SingletonRegister(c);
sw.Stop();
}
else
{
sw.Start();
c = (WindsorContainer)testCase.TransientRegister(c);
sw.Stop();
}
result.RegisterTime = sw.ElapsedMilliseconds;
sw.Reset();
result.ResolveTime = DoResolve(sw, testCase, c, testCasesNumber, singleton);
c.Dispose();
return result;
}
示例14: RegisterControllers_uses_lifestyle_transient
public void RegisterControllers_uses_lifestyle_transient()
{
var sut = new WindsorContainer();
sut.Install(new WpfInstaller());
sut.RegisterControllers(Assembly.GetAssembly(typeof(TerminalController)));
Assert.AreNotSame(sut.Resolve(typeof (TerminalController)), sut.Resolve(typeof (TerminalController)));
sut.Dispose();
}
示例15: 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);
}