本文整理匯總了C#中System.IocContainer.GetRegistrations方法的典型用法代碼示例。如果您正苦於以下問題:C# IocContainer.GetRegistrations方法的具體用法?C# IocContainer.GetRegistrations怎麽用?C# IocContainer.GetRegistrations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IocContainer
的用法示例。
在下文中一共展示了IocContainer.GetRegistrations方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: NonGenericGetRegistrationsIncludesAllButOnlyExpectedRegistrations
public void NonGenericGetRegistrationsIncludesAllButOnlyExpectedRegistrations()
{
using (var iocContainer = new IocContainer())
{
var namelessFoo = iocContainer.Register(typeof(IFoo), c => new Foo1());
var bobFoo = iocContainer.Register("Bob", typeof(IFoo), c => new Foo2());
var billFoo = iocContainer.Register("Bill", typeof(IFoo), c => new Foo2());
var janeBar = iocContainer.Register("Jane", typeof(IBar), c => new Bar1());
var result = iocContainer.GetRegistrations(typeof(IFoo));
Verify.That(result.ToList()).IsACollectionThat()
.IsAnInstanceOfType(typeof(List<IRegistration>))
.Count().IsEqualTo(3)
.AllItemsAreInstancesOfType(typeof(IRegistration))
.Contains(namelessFoo)
.Contains(bobFoo)
.Contains(billFoo)
.DoesNotContain(janeBar);
}
}
示例2: GetRegistrationsReturnsAnEmptyListIfNoRegistrationsOfTheRequesetedType
public void GetRegistrationsReturnsAnEmptyListIfNoRegistrationsOfTheRequesetedType()
{
using (var iocContainer = new IocContainer())
{
iocContainer.Register<IFoo>(c => new Foo1());
iocContainer.Register<IFoo>("Bob", c => new Foo2());
iocContainer.Register<IFoo>("Bill", c => new Foo2());
var result = iocContainer.GetRegistrations<IBar>();
Verify.That(result.ToList()).IsACollectionThat()
.IsAnInstanceOfType(typeof(List<IRegistration>))
.Count().IsEqualTo(0);
}
}