public void OnRegister(IInjectionContainer container) { // Bind the command dispatcher to a singleton, so every command can receive the instance. container.Bind <ICommandDispatcher>().ToSingleton <CommandDispatcher>(); // Bind the command pool to the CommandDispatcher. var dispatcher = (CommandDispatcher)container.Resolve <ICommandDispatcher>(); container.Bind <ICommandPool>().To <CommandDispatcher>(dispatcher); }
public void OnRegister(IInjectionContainer container) { //Binds the command dispatcher to a singleton, so every command can //receive the instance. container.Bind<ICommandDispatcher>().ToSingleton<CommandDispatcher>(); //Binds the command pool to the CommandDispatcher. var dispatcher = (CommandDispatcher)container.Resolve<ICommandDispatcher>(); container.Bind<ICommandPool>().To<CommandDispatcher>(dispatcher); }
/// <summary> /// Installs the crow components. /// </summary> /// <param name="container"></param> /// <param name="queryStore"></param> public void Install(IInjectionContainer container, IQueryStore queryStore) { container.Bind<ILog, DefaultLogger>(); container.Bind<IFileOperations, FSFileOperations>(); container.Bind<IConfigurationHelper, ApplicationConfigurationHelper>(); container.Bind<IMessagingService, DebugMessagesService>(); container.Bind<IAccountService, UnsafeAccountService>(); container.Bind<IDialectProvider, SqlDialectProvider>(); container.Bind<ICacheManager, InMemoryCacheManager>(); container.Bind<ITemplateEngine, PoorMansTemplating>(); container.Bind<IAssemblyLoader, FileAssemblyLoader>(); container.Bind<IItemManager, ThreadItemManager>(); }
/// <summary> /// 在容器中绑定指定命名空间中的所有类型为值,ICommand 为 type 的多个 binding,再将其存入对象池 /// </summary> public static IInjectionContainer RegisterCommands(this IInjectionContainer container, string namespaceName, bool includeChildren) { // 获取指定命名空间下实现了 ICommand 的类型 var commands = TypeUtils.GetAssignableTypes(typeof(ICommand), namespaceName, includeChildren); // 如果不为空,就讲其类型作为值逐一绑定一条 ICommand 类型的 TEMP binding if (commands.Length > 0) { for (var i = 0; i < commands.Length; i++) { var commandType = commands[i]; if (!commandType.IsAbstract) { container.Bind <ICommand>().To(commandType); } } // 为容器实例化一个 ICommandPool(CommandDispatcher)实例,并将容器内的所有 commands // 实例化、注入并存入对象池(储存为 List<ICommand> 并根据类型添加到 CommandDispatcher // 的字典中) PoolCommands(container); } return(container); }
public void Install(IInjectionContainer container, IQueryStore queryStore) { container.Bind<IBusiness, DataBusiness>(); queryStore.ConnectionString = new Crow.Library.Foundation.Common.ConnectionStringInformation("Data Source=.;Initial Catalog=Test;User Id=sa;Password=Aa123456"); queryStore.Expression<IDataRepository, Data>("GetDataById").Where<int>((m, id) => m.Id == id).AddToStore(); }
public void SetupBindings(IInjectionContainer container) { container //Bind the "CubeA" prefab. .Bind<Transform>().ToPrefabSingleton("06_BindingsSetup/CubeA") //Bind the "CubeB" prefab. .Bind<Transform>().ToPrefabSingleton("06_BindingsSetup/CubeB") //Bind the "CubeC" prefab. .Bind<Transform>().ToPrefabSingleton("06_BindingsSetup/CubeC"); }
public void SetupBindings(IInjectionContainer container) { container //Bind the "CubeA" prefab. .Bind <Transform>().ToPrefabSingleton("06_BindingsSetup/CubeA") //Bind the "CubeB" prefab. .Bind <Transform>().ToPrefabSingleton("06_BindingsSetup/CubeB") //Bind the "CubeC" prefab. .Bind <Transform>().ToPrefabSingleton("06_BindingsSetup/CubeC"); }
/// <summary> /// 在容器中绑定一个以指定类型为值,ICommand 为 type 的 binding. /// 执行后,可调用 PoolCommands 方法来储存所有 command 到对象池. /// RegisterCommands 方法用于使 command 准备进入对象池. /// </summary> public static IInjectionContainer RegisterCommand(this IInjectionContainer container, Type type) { if (!type.IsClass && type.IsAssignableFrom(typeof(ICommand))) { throw new Exceptions(Exceptions.TYPE_NOT_A_COMMAND); } container.Bind <ICommand>().To(type); return(container); }
public void Install(IInjectionContainer container, IQueryStore queryStore) { string provider = "System.Data.SqlClient"; string connectionString = "Data Source=.;Initial Catalog=Test;User Id=sa;Password=Aa123456"; queryStore.ConnectionString = new ConnectionStringInformation(connectionString, provider); queryStore.Expression<IDataRepository, Data>("LoadDataById") .Select() .Where<int>((data, id) => data.Id == id) .OrderBy((d) => d.Id) .AddToStore(); container.Bind<IDataBusiness, DataBusinessClass>(); }
public void Install(IInjectionContainer container, IQueryStore queryStore) { container.Bind<IHttpHost, AspNetSelfHosting>(); container.Bind<ICrowHttpHandler, HttpCrowDispatcher>(); container.Bind<INamingConvention, DefaultNamingConvention>(); container.Bind<ICrow, CrowDocumentationController>(); container.Bind<ICrowHttpHost, CrowHost>(); container.Bind<IHostConfiguration, HostConfiguration>(); container.Bind<IBusinessControllerSelector, CrowBusinessControllerSelector>(); }
public void SetupBindings(IInjectionContainer container) { container .Bind <CubeRotationSpeed>().To(new CubeRotationSpeed(0.5f)).When( context => context.parentInstance is MonoBehaviour && ((MonoBehaviour)context.parentInstance).name.Contains("CubeA")) .Bind <CubeRotationSpeed>().To(new CubeRotationSpeed(2.0f)).When( context => context.parentInstance is MonoBehaviour && ((MonoBehaviour)context.parentInstance).name.Contains("CubeB")) .Bind <CubeRotationSpeed>().To(new CubeRotationSpeed(4.5f)).When( context => context.parentInstance is MonoBehaviour && ((MonoBehaviour)context.parentInstance).name.Contains("CubeC")); }
/// <summary> /// Register a command for a given type. /// </summary> /// <param name="commandType">Type to be registered.</param> private void RegisterCommand(Type commandType) { if (!commandType.IsClass && commandType.IsAssignableFrom(typeof(ICommand))) { throw new CommandException(CommandException.TYPE_NOT_A_COMMAND); } if (!commandType.IsAbstract) { container.Bind <ICommand>().To(commandType); this.PoolCommand(commandType); } }
public void SetupBindings(IInjectionContainer container) { container //Bind the rotation data for "CubeA". .Bind<CubeRotationSpeed>().To(new CubeRotationSpeed(0.5f)).When( context => context.parentInstance is MonoBehaviour && ((MonoBehaviour)context.parentInstance).name.Contains("CubeA")) //Bind the rotation data for "CubeB". .Bind<CubeRotationSpeed>().To(new CubeRotationSpeed(2.0f)).When( context => context.parentInstance is MonoBehaviour && ((MonoBehaviour)context.parentInstance).name.Contains("CubeB")) //Bind the rotation data for "CubeC". .Bind<CubeRotationSpeed>().To(new CubeRotationSpeed(4.5f)).When( context => context.parentInstance is MonoBehaviour && ((MonoBehaviour)context.parentInstance).name.Contains("CubeC")); }
/// <summary> /// Register all commands from a given namespace. /// /// After registration, all commands are pooled. /// </summary> /// <param name="container">The container in which the command will be registered.</param> /// <param name="includeChildren">Indicates whether child namespaces should be included.</param> /// <param name="namespaceName">Namespace name.</param> /// <returns>The injection container for chaining.</returns> public static IInjectionContainer RegisterCommands(this IInjectionContainer container, string namespaceName, bool includeChildren) { var commands = TypeUtils.GetAssignableTypesInNamespace(typeof(ICommand), namespaceName, includeChildren); if (commands.Length > 0) { for (var cmdIndex = 0; cmdIndex < commands.Length; cmdIndex++) { var commandType = commands[cmdIndex]; if (!commandType.IsAbstract) { container.Bind <ICommand>().To(commandType); } } PoolCommands(container); } return(container); }
private void BindControllers(IInjectionContainer container) { container .Bind <IUserTouchController>().To <UserTouchController>() .Bind <IVehicleController>().To <VehicleController>(); }
public void Install(IInjectionContainer container, IQueryStore queryStore) { container.Bind<ITestBusiness, TestBusiness>(); }
public void SetupBindings(IInjectionContainer container) { //Bind "GameObject" to the "CubeFactory". container.Bind<GameObject>().ToFactory<CubeFactory>(); }
public void SetupBindings(IInjectionContainer container) { // Bind "GameObject" to the "CubeFactory". container.Bind <GameObject>().ToFactory <CubeFactory>(); }
public void Install(IInjectionContainer container, IQueryStore queryStore) { container.Bind<IFakeUserBusiness, FakeUserBusiness>(); }