当前位置: 首页>>代码示例>>C#>>正文


C# StandardKernel.GetAll方法代码示例

本文整理汇总了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;
 }
开发者ID:oleksiyo,项目名称:RulesEngineSamples,代码行数:7,代码来源:Validator.cs

示例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;
                }
            }
        }
开发者ID:RorySeabrook,项目名称:RobotWars,代码行数:29,代码来源:Program.cs

示例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));
        }
开发者ID:cbenoist,项目名称:Slech,代码行数:10,代码来源:Global.asax.cs

示例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;
 }
开发者ID:CaffeineMachine,项目名称:QueryPerformanceComparer,代码行数:10,代码来源:MainWindow.xaml.cs

示例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);
            }
        }
开发者ID:oravecjakub,项目名称:KInspector,代码行数:20,代码来源:ModuleLoader.cs

示例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));
        }
开发者ID:tugberkugurlu,项目名称:TourismDictionary,代码行数:10,代码来源:Global.asax.cs

示例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();
        }
开发者ID:tarwn,项目名称:StaticVoid.OrmPerformance,代码行数:55,代码来源:Program.cs

示例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);
 }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:11,代码来源:Program.cs

示例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;
        }
开发者ID:TylerGarlick,项目名称:NexBusiness.Components.Email,代码行数:17,代码来源:NinjectWebCommon.cs

示例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();
        }
开发者ID:jarrettmeyer,项目名称:RestBugs,代码行数:14,代码来源:ServiceConfiguration.cs

示例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());
        }
开发者ID:AnthonySteele,项目名称:IoCComparison,代码行数:14,代码来源:NinjectTest.cs

示例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());
        }
开发者ID:AnthonySteele,项目名称:IoCComparison,代码行数:16,代码来源:NinjectTest.cs

示例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();
        }
开发者ID:Ulriksen,项目名称:OpenSonos,代码行数:16,代码来源:Program.cs

示例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;
        }
开发者ID:robfinner,项目名称:Thinktecture.Web.Http,代码行数:19,代码来源:Program.cs


注:本文中的Ninject.StandardKernel.GetAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。