本文整理汇总了C#中Ninject.StandardKernel.GetAll方法的典型用法代码示例。如果您正苦于以下问题:C# StandardKernel.GetAll方法的具体用法?C# StandardKernel.GetAll怎么用?C# StandardKernel.GetAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ninject.StandardKernel
的用法示例。
在下文中一共展示了StandardKernel.GetAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetModules
public IEnumerable<IValidationDefinition> GetModules()
{
IKernel kernel = new StandardKernel();
kernel.Load(Assembly.GetExecutingAssembly());
var modules = kernel.GetAll<IValidationDefinition>().ToList();
return modules;
}
示例2: Main
static void Main(string[] args)
{
var kernel = new StandardKernel();
BuildDependencies(kernel);
var commandReaders = kernel.GetAll<ICommandReader>().ToList();
bool exit = false;
while (!exit)
{
var command = Console.ReadLine();
if (command == "exit" || command == "quit")
{
exit = true;
continue;
}
foreach (var commandReader in commandReaders)
{
if (!commandReader.Validate(command))
{
continue;
}
commandReader.Process(command);
break;
}
}
}
示例3: Configure
public static void Configure(HttpConfiguration config)
{
config.Filters.Add(new ValidationActionFilter());
var kernel = new StandardKernel();
kernel.Bind<ISlechRepository>().ToConstant(new InitialData());
config.ServiceResolver.SetResolver(
t => kernel.TryGet(t),
t => kernel.GetAll(t));
}
示例4: MainWindow
public MainWindow()
{
InitializeComponent();
IKernel kernel = new StandardKernel();
LibraryLoader.LoadAllBinDirectoryAssemblies();
if (File.Exists("TypeMappings.xml"))
kernel.Load("TypeMappings.xml");
var plugins = kernel.GetAll<IPlugin>().ToList();
PluginsListView.ItemsSource = plugins;
}
示例5: LoadModules
private static void LoadModules()
{
var kernel = new StandardKernel();
kernel.Bind(c =>
c.FromAssembliesInPath("./")
.SelectAllClasses()
.InheritedFrom<IModule>()
.BindAllInterfaces());
foreach (var module in kernel.GetAll<IModule>())
{
string name = module.GetModuleMetadata().Name;
if (mModules.ContainsKey(name))
{
throw new ArgumentException("Module with the name '{0}' already exists!", name);
}
mModules.Add(name, module);
}
}
示例6: RegisterDependenciesViaNinject
public static void RegisterDependenciesViaNinject(HttpConfiguration httpConfiguration)
{
var kernel = new StandardKernel();
kernel.Bind<IWordRepository>().To<WordRepository>();
kernel.Bind<IMeaningRepository>().To<MeaningRepository>();
httpConfiguration.ServiceResolver.SetResolver(
t => kernel.TryGet(t),
t => kernel.GetAll(t));
}
示例7: Main
static void Main(string[] args)
{
IKernel kernel = new StandardKernel(new OrmConfigurationModule(), new HarnessModule());
var config = kernel.Get<IRunnerConfig>();
List<List<ScenarioResult>> allRunResults = new List<List<ScenarioResult>>();
for (int i = 0; i < config.NumberOfRuns; i++)
{
Console.WriteLine(String.Format("Starting run number {0} at {1}", i, DateTime.Now.ToShortTimeString()));
allRunResults.Add(kernel.Get<ScenarioRunner>().Run(config.MaximumSampleSize));
}
var compiledResults = new List<CompiledScenarioResult>();
foreach (var result in allRunResults[0])
{
var results = from set in allRunResults
from res in set
where res.ConfigurationName == result.ConfigurationName
where res.SampleSize == result.SampleSize
where res.ScenarioName == result.ScenarioName
where res.Technology == result.Technology
select res;
compiledResults.Add(new CompiledScenarioResult
{
ConfigurationName = result.ConfigurationName,
SampleSize = result.SampleSize,
ScenarioName = result.ScenarioName,
Technology = result.Technology,
MinSetupTime = results.OrderBy(r => r.SetupTime).Take(results.Count() - config.DiscardWorst).Min(r=>r.SetupTime),
AverageSetupTime = results.OrderBy(r => r.SetupTime).Take(results.Count() - config.DiscardWorst).Average(r => r.SetupTime),
MaxSetupTime = results.OrderBy(r => r.SetupTime).Take(results.Count() - config.DiscardWorst).Max(r => r.SetupTime),
MinApplicationTime = results.OrderBy(r => r.ApplicationTime).Take(results.Count() - config.DiscardWorst).Min(r => r.ApplicationTime),
AverageApplicationTime = results.OrderBy(r => r.ApplicationTime).Take(results.Count() - config.DiscardWorst).Average(r => r.ApplicationTime),
MaxApplicationTime = results.OrderBy(r => r.ApplicationTime).Take(results.Count() - config.DiscardWorst).Max(r => r.ApplicationTime),
MinCommitTime = results.OrderBy(r => r.CommitTime).Take(results.Count() - config.DiscardWorst).Min(r => r.CommitTime),
AverageCommitTime = results.OrderBy(r => r.CommitTime).Take(results.Count() - config.DiscardWorst).Average(r => r.CommitTime),
MaxCommitTime = results.OrderBy(r => r.CommitTime).Take(results.Count() - config.DiscardWorst).Max(r => r.CommitTime),
Status = results.OrderByDescending(r => (int) r.Status.State).Select(r=> r.Status).FirstOrDefault() ?? new AssertionPass(),
MemoryUsage = results.Count() > config.DiscardWorst + config.DiscardHighestMemory
? results.OrderBy(r => r.MemoryUsage).Take(results.Count() - config.DiscardWorst)
.OrderByDescending(r => r.MemoryUsage).Take(results.Count() - config.DiscardWorst -config.DiscardHighestMemory).Average(r => r.MemoryUsage)
: results.Average(r=>r.MemoryUsage)
});
}
foreach (var formatter in kernel.GetAll<IResultFormatter<CompiledScenarioResult>>())
{
formatter.FormatResults(compiledResults);
}
Console.ReadLine();
}
示例8: ThreadedPerformanceSessionControl
public ThreadedPerformanceSessionControl()
{
InitializeComponent();
_testUrls = new List<string>();
IKernel kernel = new StandardKernel();
LibraryLoader.LoadAllBinDirectoryAssemblies();
if (File.Exists("TypeMappings.xml"))
kernel.Load("TypeMappings.xml");
var plugins = kernel.GetAll<IThreadedPerformanceSessionTestUrlGenerator>().ToList();
UrlGeneratorPlugins.ItemsSource = plugins.ToList();
}
开发者ID:CaffeineMachine,项目名称:QueryPerformanceComparer,代码行数:11,代码来源:ThreadedPerformanceSessionControl.xaml.cs
示例9: Main
public static void Main(string[] args)
{
var kernel = new StandardKernel();
kernel.Load<TychaiaGlobalIoCModule>();
kernel.Load<TychaiaProceduralGenerationIoCModule>();
kernel.Load<TychaiaToolIoCModule>();
ConsoleCommandDispatcher.DispatchCommand(
kernel.GetAll<ConsoleCommand>(),
args,
Console.Out);
}
示例10: CreateKernel
/// <summary>
/// Creates the kernel that will manage your application.
/// </summary>
/// <returns>The created kernel.</returns>
private static IKernel CreateKernel()
{
var kernel = new StandardKernel();
kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
RegisterServices(kernel);
DependencyResolver.SetResolver(t => kernel.TryGet(t), t => kernel.GetAll(t));
GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
return kernel;
}
示例11: Configure
public static void Configure(HttpConfiguration config)
{
config.Routes.MapHttpRoute("def", "bugs/{controller}", new {controller = "Index"});
config.Formatters.Add(new RazorHtmlMediaTypeFormatter());
config.MessageHandlers.Add(new EtagMessageHandler());
var kernel = new StandardKernel();
kernel.Bind<IBugRepository>().To<StaticBugRepository>();
config.ServiceResolver.SetResolver(t => kernel.TryGet(t), t => kernel.GetAll(t));
AutoMapperConfig.Configure();
}
示例12: CanGetAllValidators
public void CanGetAllValidators()
{
IKernel kernel = new StandardKernel();
kernel.Scan(scanner =>
{
scanner.From(typeof(IValidator).Assembly);
scanner.WhereTypeInheritsFrom<IValidator>();
scanner.BindWith<NinjectServiceToInterfaceBinder>();
});
var validators = kernel.GetAll<IValidator>();
Assert.IsNotNull(validators);
Assert.AreEqual(3, validators.Count());
}
示例13: CanFilterOutValidatorRegistrations
public void CanFilterOutValidatorRegistrations()
{
IKernel kernel = new StandardKernel();
kernel.Scan(scanner =>
{
scanner.From(typeof(IValidator).Assembly);
scanner.WhereTypeInheritsFrom<IValidator>();
// excluding the FailValidator should leave 2 of them
scanner.Where(t => t != typeof(FailValidator));
scanner.BindWith<NinjectServiceToInterfaceBinder>();
});
var validators = kernel.GetAll<IValidator>();
Assert.IsNotNull(validators);
Assert.AreEqual(2, validators.Count());
}
示例14: Main
public static void Main(string[] args)
{
var kernel = new StandardKernel(new Bindings());
new Service(args,
()=> kernel.GetAll<IWindowsService>().ToArray(),
installationSettings: (serviceInstaller, serviceProcessInstaller) =>
{
serviceInstaller.ServiceName = "OpenSonos.LocalMusicServer.Service";
serviceInstaller.StartType = ServiceStartMode.Automatic;
serviceProcessInstaller.Account = ServiceAccount.NetworkService;
},
configureContext: x => { x.Log = Console.WriteLine; },
registerContainer: () => new SimpleServicesToNinject(kernel))
.Host();
}
示例15: SetupWebApiServer
private static HttpSelfHostServer SetupWebApiServer(string url)
{
var ninjectKernel = new StandardKernel();
ninjectKernel.Bind<IContactRepository>().To<InMemoryContactRepository>();
var configuration = new HttpSelfHostConfiguration(url);
configuration.ServiceResolver.SetResolver(
t => ninjectKernel.TryGet(t),
t => ninjectKernel.GetAll(t));
configuration.Routes.MapHttpRoute(
"Default",
"{controller}/{id}/{ext}",
new {id = RouteParameter.Optional, ext = RouteParameter.Optional});
var host = new HttpSelfHostServer(configuration);
return host;
}