本文整理汇总了C#中StandardKernel类的典型用法代码示例。如果您正苦于以下问题:C# StandardKernel类的具体用法?C# StandardKernel怎么用?C# StandardKernel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StandardKernel类属于命名空间,在下文中一共展示了StandardKernel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransientBindingsWork
public void TransientBindingsWork()
{
var kernel = new StandardKernel();
kernel.Get(
typeof (IInput),
null,
null,
null,
null,
null,
new Dictionary<Type, List<IMapping>>
{
{
typeof (IInput), new List<IMapping>
{
new DefaultMapping(
typeof(DefaultInput),
null,
false,
null,
null,
false,
false,
null)
}
}
});
}
示例2: IsNotOverlappingWhenNoBoundingBoxes
public void IsNotOverlappingWhenNoBoundingBoxes()
{
var kernel = new StandardKernel();
kernel.Load<ProtogameCoreModule>();
var boundingBoxUtilities = kernel.Get<IBoundingBoxUtilities>();
_assert.False(boundingBoxUtilities.Overlaps());
}
示例3: IsNotOverlappingWhenOneBoundingBox
public void IsNotOverlappingWhenOneBoundingBox()
{
var kernel = new StandardKernel();
kernel.Load<ProtogameCoreModule>();
var boundingBoxUtilities = kernel.Get<IBoundingBoxUtilities>();
_assert.False(boundingBoxUtilities.Overlaps(this.CreateBoundingBox(200, 200, 16, 16)));
}
示例4: Run
public void Run(IConfiguration configuration, IWebEnvironment environment)
{
var module = CreateModules().ToArray();
if (module.Length == 0) return;
var kernel = new StandardKernel(module);
configuration.Container = new NinjectContainer(kernel);
}
示例5: FactoryTests
public FactoryTests()
{
this.kernel = new StandardKernel();
#if NO_ASSEMBLY_SCANNING
this.kernel.Load(new FuncModule());
#endif
}
示例6: ReplaceMapper
public void ReplaceMapper() {
var c = new StandardKernel();
var mapper = new global::SolrNet.Tests.Mocks.MReadOnlyMappingManager();
c.Load(new SolrNetModule("http://localhost:8983/solr") {Mapper = mapper});
var m = c.Get<IReadOnlyMappingManager>();
Assert.AreSame(mapper, m);
}
示例7: Container
static Container()
{
if (Kernel == null)
{
Kernel = new StandardKernel(new ClientModule());
}
}
示例8: GetBindingInformations
public List<FeatureInfo> GetBindingInformations(INinjectModule module)
{
List<FeatureInfo> bindingsFeatureInfoList = new List<FeatureInfo>();
IKernel kernel = new StandardKernel();
module.OnLoad(kernel);
List<KeyValuePair<Type, ICollection<IBinding>>> typeBindingInfo = GetBindings(kernel, module.Name);
foreach (KeyValuePair<Type, ICollection<IBinding>> typeBinding in typeBindingInfo)
{
FeatureInfo bindingInterface = new FeatureInfo(typeBinding.Key, null, null, FeatureType.BindingInterface);
foreach (IBinding binding in typeBinding.Value)
{
ContextMock contextMock = new ContextMock(kernel);
IProvider provider = binding.ProviderCallback(contextMock);
FeatureInfo bindingInterfaceImpl = new FeatureInfo(provider.Type, null, null, FeatureType.BindingImpl);
bindingInterfaceImpl.SetBindingType(binding.Target);
bindingInterface.AddDependency(bindingInterfaceImpl);
}
bindingsFeatureInfoList.Add(bindingInterface);
}
return bindingsFeatureInfoList;
}
示例9: FactoryProviderContext
public FactoryProviderContext()
{
contextMock = new Mock<IContext>();
kernel = new StandardKernel();
contextMock.SetupGet(c => c.Kernel).Returns(kernel);
}
示例10: InstanceIsDeactivatedWhenItLeavesScope
public void InstanceIsDeactivatedWhenItLeavesScope()
{
Barracks barracks;
using ( var kernel = new StandardKernel() )
{
kernel.Bind<Barracks>()
.ToSelf()
.InSingletonScope()
.OnActivation(instance =>
{
instance.Warrior = new FootSoldier();
instance.Weapon = new Shuriken();
})
.OnDeactivation(instance =>
{
instance.Warrior = null;
instance.Weapon = null;
});
barracks = kernel.Get<Barracks>();
barracks.Warrior.ShouldNotBeNull();
barracks.Warrior.ShouldBeInstanceOf<FootSoldier>();
barracks.Weapon.ShouldNotBeNull();
barracks.Weapon.ShouldBeInstanceOf<Shuriken>();
}
barracks.Warrior.ShouldBeNull();
barracks.Weapon.ShouldBeNull();
}
示例11: ManyPublishersManySubscribers
public void ManyPublishersManySubscribers()
{
using ( var kernel = new StandardKernel() )
{
var pub1 = kernel.Get<PublisherMock>();
var pub2 = kernel.Get<PublisherMock>();
Assert.NotNull( pub1 );
Assert.NotNull( pub2 );
var sub1 = kernel.Get<SubscriberMock>();
var sub2 = kernel.Get<SubscriberMock>();
Assert.NotNull( sub1 );
Assert.NotNull( sub2 );
Assert.True( pub1.HasListeners );
Assert.True( pub2.HasListeners );
Assert.Null( sub1.LastMessage );
Assert.Null( sub2.LastMessage );
pub1.SendMessage( "Hello, world!" );
Assert.Equal( sub1.LastMessage, "Hello, world!" );
Assert.Equal( sub2.LastMessage, "Hello, world!" );
sub1.LastMessage = null;
sub2.LastMessage = null;
Assert.Null( sub1.LastMessage );
Assert.Null( sub2.LastMessage );
pub2.SendMessage( "Hello, world!" );
Assert.Equal( sub1.LastMessage, "Hello, world!" );
Assert.Equal( sub2.LastMessage, "Hello, world!" );
}
}
示例12: Ping_And_Query
public void Ping_And_Query()
{
var c = new StandardKernel();
c.Load(new SolrNetModule("http://localhost:8983/solr"));
var solr = c.Get<ISolrOperations<Entity>>();
solr.Ping();
Console.WriteLine(solr.Query(SolrQuery.All).Count);
}
示例13: IsNotOverlappingWhenSameBoundingBoxAndNoOtherBoxes
public void IsNotOverlappingWhenSameBoundingBoxAndNoOtherBoxes()
{
var kernel = new StandardKernel();
kernel.Load<ProtogameCoreModule>();
var boundingBoxUtilities = kernel.Get<IBoundingBoxUtilities>();
var entity = this.CreateBoundingBox(200, 200, 16, 16);
_assert.False(boundingBoxUtilities.Overlaps(entity, entity));
}
示例14: NinjectTraceLogger
/// <summary>
/// Initializes a new instance of the <see cref="NinjectTraceLogger" /> class.
/// </summary>
public NinjectTraceLogger()
{
var kernel = new StandardKernel();
this.logger = kernel.Get<ILoggerFactory>().GetCurrentClassLogger();
this.beginTraces = new List<TraceRecord>();
}
示例15: UsageHandler
/// <summary>
/// Initializes a new instance of the <see cref="UsageHandler" /> class.
/// </summary>
public UsageHandler()
{
var kernel = new StandardKernel();
var logfactory = kernel.Get<ILoggerFactory>();
this.Log = logfactory.GetCurrentClassLogger();
}