/// <summary> /// Configures the DI container /// </summary> /// <returns>configured kernel</returns> static IKernel Configure() { var kernel = new StandardKernel(); //TODO: Move this to a module kernel.Bind<IClock> ().To<LinuxSystemClock> ().InSingletonScope (); //infrastructure modules kernel.Load(new List<NinjectModule>() { new LoggingModule(new List<string>(){"Log.config"}) }); var logger = kernel.Get<ILogger> (); logger.Info ("Loading Plugins..."); //plugins kernel.Load (new string[] { "*.Plugin.dll" }); logger.Info ("Loading Core..."); //core services/controllers kernel.Bind<IRaceController>().To<RaceController>() .InSingletonScope() .WithConstructorArgument("autoRoundMarkDistanceMeters", AppConfig.AutoRoundMarkDistanceMeters); kernel.Bind<Supervisor>().ToSelf() .InSingletonScope() .WithConstructorArgument("cycleTime", AppConfig.TargetCycleTime); return kernel; }
protected override IKernel CreateKernel() { var kernel = new StandardKernel(); NinjectModule[] modules = new NinjectModule[] { new WebModule() }; kernel.Load(Assembly.GetExecutingAssembly()); kernel.Load(modules); return kernel; }
/// <summary> /// Creates the kernel that will manage your application. /// </summary> /// <returns> /// The created kernel. /// </returns> protected override IKernel CreateKernel() { var kernel = new StandardKernel(); kernel.Load(new CoreModule()); kernel.Load(new DataModule()); return kernel; }
public static void Initialize() { var kernel = new StandardKernel(new RegistrationModule()); kernel.Load("DD4T.ContentModel.Contracts"); kernel.Load("DD4T.Factories"); kernel.Load("DD4T.Providers.Test"); kernel.Load("DD4T.ViewModels"); PageFactory = kernel.Get<IPageFactory>(); ComponentPresentationFactory = kernel.Get<IComponentPresentationFactory>(); ComponentFactory = kernel.Get<IComponentFactory>(); PageFactory.CacheAgent = kernel.Get<ICacheAgent>(); PageFactory.PageProvider = kernel.Get<IPageProvider>(); ComponentPresentationFactory.CacheAgent = kernel.Get<ICacheAgent>(); ComponentPresentationFactory.ComponentPresentationProvider = kernel.Get<IComponentPresentationProvider>(); ((ComponentFactory)ComponentFactory).ComponentPresentationFactory = ComponentPresentationFactory; ((TridionPageProvider)PageFactory.PageProvider).SerializerService = kernel.Get<ISerializerService>(); ((TridionComponentPresentationProvider)ComponentPresentationFactory.ComponentPresentationProvider).SerializerService = kernel.Get<ISerializerService>(); ((TridionPageProvider)PageFactory.PageProvider).ComponentPresentationProvider = ComponentPresentationFactory.ComponentPresentationProvider; kernel.Bind<IViewModelKeyProvider>().To <WebConfigViewModelKeyProvider>(); kernel.Bind<IViewModelResolver>().To<DefaultViewModelResolver>(); kernel.Bind<IViewModelFactory>().To<ViewModelFactory>(); kernel.Bind<IReflectionHelper>().To<ReflectionOptimizer>(); ViewModelFactory = kernel.Get<IViewModelFactory>(); ViewModelFactory.LoadViewModels(new [] { typeof(TestViewModelA).Assembly }); }
private static IKernel LoadKernel() { var kernel = new StandardKernel(); kernel.Load<HEWFitnessWebModule>(); kernel.Load<HEWFitnessAutomationFrameworkModule>(); return kernel; }
protected override Ninject.IKernel CreateKernel() { var kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); kernel.Load(new List<String>() { "Tartan.Services.*" }); return kernel; }
public Working() { // 1 create the kernel var kernel = new StandardKernel(); kernel.Bind<ICreditCard>().To<Visa>(); kernel.Bind<ICreditCard>().To<MasterCard>().InSingletonScope(); kernel.Bind<Shopper>().ToSelf().InSingletonScope(); // 5 modules kernel.Load(new WorkingModule()); // 6 xml config kernel.Load(Helpers.AssemblyDirectory + "\\*.xml"); // 7 conventions kernel.Bind(x => x .FromAssembliesInPath(Helpers.AssemblyDirectory) .SelectAllClasses() .InheritedFrom<ICreditCard>() .BindDefaultInterfaces() .Configure(b => b.InSingletonScope() .WithConstructorArgument("name", "BackupCard")) //.ConfigureFor<Shopper>(b => b.InThreadScope()) ); }
public void ConstructorCreatedCorrectly() { var kernel = new StandardKernel(); kernel.Load(new ThingsToDoCityModule()); kernel.Load(new AppModule()); var controller = kernel.Get<EventController>(); }
public static IKernel Initialize(params NinjectModule[] modules) { var kernel = new StandardKernel(); kernel.Load(new FoundationModule()); kernel.Load(modules); return kernel; }
public static void Init() { var kernel = new StandardKernel(); kernel.Load(new DbNinjectModule()); kernel.Load(new WebNinjectModule()); kernel.Load(new LogicNinjectModule()); Kernel = kernel; }
public static IKernel CreateKernel() { var kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); kernel.Load(new NinjectServiceModule()); kernel.Load(new NinjectDataModule()); return kernel; }
public void TestInitialize() { var kernel = new StandardKernel(); kernel.Load<StorageModule>(); kernel.Load<LogicModule>(); SecurityContext = Substitute.For<ISecurityContext>(); SecurityContext.CurrentUser.Returns(new User { Id = 1 }); Target = new PayPalCreditCardService(kernel.Get<IConfigurationHelper>(), SecurityContext); }
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); }
protected RuntimeLayer CreateRuntimeLayer(IAlgorithm algorithm) { var kernel = new StandardKernel(); kernel.Load<TychaiaGlobalIoCModule>(); kernel.Load<TychaiaProceduralGenerationIoCModule>(); kernel.Load<Protogame3DIoCModule>(); kernel.Load<ProtogameAssetIoCModule>(); kernel.Bind<IAssetContentManager>().To<NullAssetContentManager>(); kernel.Bind<IAssetManagerProvider>().To<LocalAssetManagerProvider>(); return kernel.Get<IRuntimeLayerFactory>().CreateRuntimeLayer(algorithm); }
public static void Main(string[] args) { var kernel = new StandardKernel(); kernel.Load<Protogame2DIoCModule>(); kernel.Load<ProtogameAssetIoCModule>(); AssetManagerClient.AcceptArgumentsAndSetup<GameAssetManagerProvider>(kernel, args); using (var game = new {PROJECT_SAFE_NAME}Game(kernel)) { game.Run(); } }
public void IsNotOnGroundWhenJustAboveTheGround() { var kernel = new StandardKernel(); kernel.Load<Protogame2DIoCModule>(); kernel.Load<ProtogamePlatformingIoCModule>(); var platforming = kernel.Get<IPlatforming>(); var player = this.CreateBoundingBox(200, 200 - 17, 16, 16); var ground = this.CreateBoundingBox(0, 200, 400, 16); Assert.False(platforming.IsOnGround( player, new[] { player, ground }, x => true)); }
public void GravityIsAppliedWhenGravityIsPositive() { var kernel = new StandardKernel(); kernel.Load<Protogame2DIoCModule>(); kernel.Load<ProtogamePlatformingIoCModule>(); var platforming = kernel.Get<IPlatforming>(); var boundingBox = this.CreateBoundingBox(0, 0, 0, 0, 0, 0); platforming.ApplyGravity(boundingBox, 0, 10); Assert.Equal(10, boundingBox.YSpeed); platforming.ApplyGravity(boundingBox, 0, 10); Assert.Equal(20, boundingBox.YSpeed); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var kernel = new StandardKernel(); kernel.Load<Protogame2DIoCModule>(); kernel.Load<ProtogameAssetIoCModule>(); AssetManagerClient.AcceptArgumentsAndSetup<GameAssetManagerProvider>(kernel, null); // Create our OpenGL view, and display it var g = new GeneratedGame(kernel); SetContentView(g.AndroidGameView); g.Run(); }
public void RealRepository_WhenCalled_ReturnsMockData() { var kernel = new StandardKernel(); kernel.Load<AppModule>(); //Order is important. In MockModule we rebind IContextFactory. //Another option is to load MockModule only. kernel.Load<MockModule>(); var repo = kernel.Get<ReportRepository>(); var reports = repo.GetReports(); Assert.IsNotEmpty(reports); }
public void TestInitialize() { base.InitDbContext(); var kernel = new StandardKernel(); kernel.Load<StorageModuleForWCF>(); kernel.Load<LogicModule>(); kernel.Load<TaskQueueModule>(); _repository = new TaskQueueRepository(this.DbFactory); _taskQueueManager = kernel.Get<TaskQueueManager>(); _userRepository = Substitute.For<IUserRepository>(); ClearTaskQueueContext(); }
static void Main(string[] args) { ActionType action = (ActionType)Enum.Parse(typeof(ActionType), args[0].Captalize()); IKernel kernel = new StandardKernel(); kernel.Load(new SharedModule(action)); kernel.Load(new MongoRepositoryModule()); kernel.Load(new InfrastructureModule()); kernel.Load(new InitializeModule()); kernel.Load(new RssCheckModule()); kernel.Load(new UpdateModule()); kernel.Load(new CheckNewModule()); kernel.Load(new RescueModule()); ConfigureLogger(action, kernel); AppDomain.CurrentDomain.ProcessExit += (target, e) => LogManager.Configuration = null; Type taskType = Type.GetType("PingApp.Schedule.Task." + action + "Task"); TaskBase task = kernel.Get(taskType) as TaskBase; if (task == null) { Console.WriteLine("No task for action {0} defined", args[0]); return; } using (task) { string[] taskArguments = new string[args.Length - 1]; Array.Copy(args, 1, taskArguments, 0, taskArguments.Length); task.Run(taskArguments); } // NLog在mono平台上有BUG,会导致程序无法退出,始终等待Logger进行Flush,这行代码强制完成Flush LogManager.Configuration = null; }
public static void Main(string[] args) { var kernel = new StandardKernel(); kernel.Load<Protogame3DIoCModule>(); kernel.Load<ProtogameAssetIoCModule>(); kernel.Load<ProtogameEventsIoCModule>(); kernel.Load<ProtogameLevelIoCModule>(); kernel.Load<PerceptionIoCModule>(); AssetManagerClient.AcceptArgumentsAndSetup<GameAssetManagerProvider>(kernel, args); using (var game = new PerceptionGame(kernel)) { game.Run(); } }
private static void Main() { var kernel = new StandardKernel(); kernel.Load<TychaiaGlobalIoCModule>(); kernel.Load<TychaiaProceduralGenerationIoCModule>(); kernel.Load<TychaiaWorldGenViewerAlgorithmIoCModule>(); kernel.Load<Protogame3DIoCModule>(); kernel.Load<ProtogameAssetIoCModule>(); kernel.Bind<IAssetContentManager>().To<NullAssetContentManager>(); kernel.Bind<IAssetManagerProvider>().To<LocalAssetManagerProvider>(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(kernel.Get<FlowForm>()); }
static void Main() { Log4NetLogger.Use("cashier.log4net.xml"); HostFactory.Run(c => { c.SetServiceName("StarbucksCashier"); c.SetDisplayName("Starbucks Cashier"); c.SetDescription("a Mass Transit sample service for handling orders of coffee."); c.RunAsLocalSystem(); c.DependsOnMsmq(); var kernel = new StandardKernel(); var module = new CashierRegistry(); kernel.Load(module); DisplayStateMachine(); c.Service<CashierService>(s => { s.ConstructUsing(builder => kernel.Get<CashierService>()); s.WhenStarted(o => o.Start()); s.WhenStopped(o => o.Stop()); }); }); }
private static IRestClient GetRestClient() { IKernel kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); return kernel.Get<IRestClient>(); }
private static StandardKernel CreateKernel() { var kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); RegisterMappings(kernel); return kernel; }
static void Main(string[] args) { DirEx direx; if (!ArgsBinder.TryParse(args, out direx)) { throw new ArgsExeption(args); } IKernel kernal = new StandardKernel(); kernal.Load(Assembly.GetExecutingAssembly()); IFileAction<string> fileAction = kernal.Get<IFileAction<string>>(); fileAction.Output = kernal.Get<IFileActionResult<string>>(); direx.OnFile += Direx_OnFileAction; direx.OnDirectory += Direx_OnDirectory; direx.Action(fileAction); if (fileAction.Output is IDisposable) ((IDisposable)fileAction.Output).Dispose(); #if DEBUG Cmd.ReadKey(); #endif }
private static void Main() { XmlConfigurator.Configure(new FileInfo("patientOrderService.log4net.xml")); HostFactory.Run( c => { c.SetServiceName("SampleSOAPatientOrderService"); c.SetDisplayName("Sample SOA Patient Order Service"); c.SetDescription("A sample SOA service for handling Patient Orders."); c.RunAsNetworkService(); StandardKernel kernel = new StandardKernel(); PatientOrderServiceRegistry module = new PatientOrderServiceRegistry(); kernel.Load(module); c.Service<PatientOrderService>( s => { s.ConstructUsing(builder => kernel.Get<PatientOrderService>()); s.WhenStarted(o => o.Start()); s.WhenStopped(o => o.Stop()); }); }); }
public void DoIt() { using (var kernel = new Ninject.StandardKernel()) { kernel.Load <Nailhang.Mongodb.Module>(); kernel.Rebind <Nailhang.Mongodb.MongoConnection>() .ToConstant(new MongoConnection { ConnectionString = "mongodb://192.168.0.32", DbName = "nail_tests" }); var ms = kernel.Get <IModulesStorage>(); ms.StoreModule(new IndexBase.Module { Assembly = "lala", Description = "big lala", FullName = "very big lala", InterfaceDependencies = new IndexBase.TypeReference[] { }, Interfaces = new IndexBase.ModuleInterface[] { }, ModuleBinds = new IndexBase.TypeReference[] { }, ObjectDependencies = new IndexBase.TypeReference[] { }, Objects = new IndexBase.ModuleObject[] { }, Significance = Significance.High }); Assert.IsNotEmpty(ms.GetModules().ToArray()); ms.DropModules("NOTREALNAMESPACE"); Assert.IsNotEmpty(ms.GetModules().ToArray()); ms.DropModules(""); Assert.IsEmpty(ms.GetModules().ToArray()); } }
static void Main(string[] args) { var uploadManager = new UploadManager(); //uploadManager.UploadRestaurantData(); IKernel kernal = new StandardKernel(); kernal.Load(Assembly.GetExecutingAssembly()); kernal.Bind(typeof(IRepository<>)).To(typeof(Repository<>)); kernal.Bind<IUserService>().To<UserService>(); kernal.Bind<IRestaurantService>().To<RestaurantService>(); kernal.Bind<IService>().To<ServiceClass>(); var service = kernal.Get<ServiceBase>(); service.ImplementServiceMember(); var restoService = kernal.Get<RestaurantServiceBase>(); restoService.GetItems(); Console.ReadLine(); }
protected override Ninject.IKernel CreateKernel() { var kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); kernel.Bind<DataService>().ToSelf().InRequestScope().WithConstructorArgument<IDataStore<DataService.RootData>>(new JsonFileDataStore<DataService.RootData>(this.Server.MapPath("~/App_Data/data.json"))); return kernel; }
/// <summary> /// The main entry point of the program. This method initializes the composition root and then launches the game session. /// </summary> /// <param name="args"></param> static void Main(string[] args) { System.Console.Title = "Card Game"; var kernel = new Ninject.StandardKernel(); kernel.Load(System.Reflection.Assembly.GetExecutingAssembly()); var gameSessionManager = kernel.Get <CardGameSessionManager>(); gameSessionManager.BeginSession(); }
public WCFSorter() { try { string[] type_of_sorter = System.IO.File.ReadAllLines(@"Sorter.txt"); var kernel = new Ninject.StandardKernel(); kernel.Load(type_of_sorter[0]); sorter = kernel.Get <ISorter>(); } catch (Exception e) { System.Console.WriteLine(e.Message); System.Console.ReadLine(); } }
public int[] Sort(int[] array) { try { var kernel = new Ninject.StandardKernel(); kernel.Load("Sort.xml"); IWCFSorter sorter = kernel.Get <IWCFSorter>(); return(sorter.Sort(array)); } catch (Exception e) { System.Console.WriteLine(e.Message); System.Console.ReadLine(); return(null); } }
public ClientContext() { RegistrationFactory = A.Fake <SignalR.Client.Registration.IFactory>(); A.CallTo(() => RegistrationFactory.For(A <IIdentity> .Ignored, A <IEntity> .Ignored, A <IObserver <IMessage> > .Ignored)) .ReturnsLazily( call => { IIdentity identity = call.GetArgument <IIdentity>(0); IEntity entity = call.GetArgument <IEntity>(1); IObserver <IMessage> observer = call.GetArgument <IObserver <IMessage> >(2); return(new SignalR.Client.Registration.Instance(identity.AsDto(), entity.AsDto(), observer)); } ); Kernel = new Ninject.StandardKernel(); Kernel.Load(new[] { new SignalR.Client.Module() }); Kernel.Bind <SignalR.Client.Registration.IFactory>().ToConstant(RegistrationFactory).InSingletonScope(); }
public static void Start() { log4net.Config.XmlConfigurator.Configure(); var kernal = new Ninject.StandardKernel(); kernal.Load(new[] { Assembly.GetExecutingAssembly() }); GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernal); var applicationConfigurationProvider = kernal.Get <IApplicationConfigurationProvider>(); applicationConfigurationProvider.SourceCodeIndexPath.EnsureDirectoryExists(); var writerLockPath = Path.Combine(applicationConfigurationProvider.SourceCodeIndexPath, "write.lock"); if (File.Exists(writerLockPath)) { File.Delete(writerLockPath); } }
static void Main(string[] args) { var kernel = new Ninject.StandardKernel(); // 加载所有定义在dll中的注册模块 var files = "NBlock*.dll,*Models.dll,*Services.dll,"; var configLoadFiles = ConfigurationManager.AppSettings["RegisterModules"] ?? ""; kernel.Load((files + configLoadFiles).Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)); // 注册服务 kernel.Bind <ILogService>().To <Log4NetService>().InSingletonScope(); // 设置依赖注入 ServiceLocator.SetLocatorProvider(() => new NinjectServiceLocator(kernel)); // 配置Log服务 ServiceLocator.Current.GetInstance <ILogService>().Configure(); // 启动服务 var host = HostFactory.New(x => { x.Service <QuartzService>(); x.SetDescription(ConfigurationManager.AppSettings["ServiceDescription"]); x.SetDisplayName(ConfigurationManager.AppSettings["ServiceDisplayName"]); x.SetServiceName(ConfigurationManager.AppSettings["ServiceName"]); x.RunAsLocalSystem(); x.StartAutomatically(); x.AfterUninstall(() => { // TODO 删除调度器表记录 LogManager.GetCurrentClassLogger().Info("服务卸载成功"); }); }); host.Run(); System.Console.ReadLine(); }
/// <summary> /// Main. /// </summary> public static void Main() { var kernel = new Ninject.StandardKernel(); // 加载所有定义在dll中的注册模块 var files = "NBlock*.dll,*Models.dll,*Services.dll,"; kernel.Load((files).Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)); // 注册服务 kernel.Bind <ILogService>().To <Log4NetService>().InSingletonScope(); // 设置依赖注入 ServiceLocator.SetLocatorProvider(() => new NinjectServiceLocator(kernel)); // 配置Log服务 ServiceLocator.Current.GetInstance <ILogService>().Configure(); // 启动服务 Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory); HostFactory.Run(x => { x.RunAsLocalSystem(); x.SetDescription(Configuration.ServiceDescription); x.SetDisplayName(Configuration.ServiceDisplayName); x.SetServiceName(Configuration.ServiceName); x.Service(factory => { QuartzServer server = QuartzServerFactory.CreateServer(); server.Initialize(); return(server); }); }); }