本文整理匯總了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);
}