當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。