本文整理汇总了C#中Container.IsConfiguredFor方法的典型用法代码示例。如果您正苦于以下问题:C# Container.IsConfiguredFor方法的具体用法?C# Container.IsConfiguredFor怎么用?C# Container.IsConfiguredFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container.IsConfiguredFor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Dispose2Test
public virtual void Dispose2Test()
{
bool disposed = false;
ITestDisposable a = null;
using (var ioc = new Container())
{
var registration = ioc.As<ITestDisposable>().Use<MockDisposableClass>(ioc); //as singleton /* AccordConatiner implements IPersunScope*/
registration.BeforeRelease += (sender, args) => { args.RunDispose = false; };
a = ioc.GetService<ITestDisposable>();
a.BeforeDisposeAction =
delegate
{
disposed = true;
};
Assert.IsTrue(ioc.IsConfiguredFor(typeof(ITestDisposable)));
}
Assert.IsFalse(disposed);
}
示例2: DisposeRegistration
public void DisposeRegistration()
{
var disposed = false;
var created = false;
using (var ioc = new Container())
{
IConfiguredFactory<MockDisposableClass> registration = ioc.As<ITestDisposable>().Use<MockDisposableClass>(ioc);
registration.AfterCreate += (sender, args) =>
{
args.Component.BeforeDisposeAction =() => disposed = true;
//((AfterCreateEventArgs)args).Component = new MockDisposableClass2();
};
var myComponent = ioc.GetService<ITestDisposable>();
registration.Dispose();
Assert.IsTrue(disposed);
Assert.IsFalse(ioc.IsConfiguredFor(typeof(ITestDisposable)));
}
}
示例3: DisposeServiceTest
public virtual void DisposeServiceTest()
{
bool disposed = false;
using (var ioc = new Container())
{
ioc.As<ITestDisposable>().Use<MockDisposableClass>(ioc); //as singleton /* AccordConatiner implements IPersunScope*/
var a = ioc.GetService<ITestDisposable>();
a.BeforeDisposeAction =
delegate
{
disposed = true;
};
Assert.IsTrue(ioc.IsConfiguredFor(typeof(ITestDisposable)));
ioc.DisposeService(typeof(ITestDisposable));
Assert.IsTrue(disposed);
Assert.IsFalse(ioc.IsConfiguredFor(typeof(ITestDisposable)));
}
}