本文整理汇总了C#中Ninject.StandardKernel.Release方法的典型用法代码示例。如果您正苦于以下问题:C# StandardKernel.Release方法的具体用法?C# StandardKernel.Release怎么用?C# StandardKernel.Release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ninject.StandardKernel
的用法示例。
在下文中一共展示了StandardKernel.Release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
IKernel kernel = new StandardKernel();
// Container Register
kernel.Bind<ILog>().ToMethod(
x =>
{
var scope = x.Request.ParentRequest.Service.FullName;
var log = (ILog)LogManager.GetLogger(scope, typeof(Log));
return log;
});
kernel.Bind<IParser>().To<FileParser>();
kernel.Bind<IResourceItemParser<string>>().To<JsonResourceItemParser>();
kernel.Bind<IVerificationProcessor<string>>().To<VerificationProcessor<string>>()
.WithConstructorArgument("factory", new StringTypeResourceVerifierFactory());
kernel.Bind<IVerificationInvoker>().To<CompositeVerifier<string>>();
// Container Resolve
IParser fileReader = kernel.Get<IParser>(new ConstructorArgument("filePath", args.First()));
VerificationResult jsonStringFromFile = fileReader.Parse();
IResourceItemParser<string> parser = kernel.Get<IResourceItemParser<string>>();
IVerificationProcessor<string> processor = kernel.Get<IVerificationProcessor<string>>();
IVerificationInvoker invoker = kernel.Get<IVerificationInvoker>(
new ConstructorArgument("parser", parser),
new ConstructorArgument("processor", processor));
var result = invoker.VerifyEnvironment(jsonStringFromFile);
foreach (VerificationResult verificationResult in result)
{
Console.ForegroundColor = GetColour(verificationResult.Type);
Console.WriteLine(string.Format("{0}", verificationResult.Message));
Console.WriteLine();
Console.ResetColor();
}
Console.WriteLine("Done ...");
Console.ReadKey();
// Container Release
kernel.Release(invoker);
kernel.Release(processor);
kernel.Release(parser);
kernel.Release(fileReader);
}