public void Install(IDependencyContainer container) { // Create an input manager and bind its implemented interfaces KeyboardInputManager keyboard = new KeyboardInputManager(); container.RegisterWithInterfaces <KeyboardInputManager>(new InstanceBinding <KeyboardInputManager>(keyboard)); if (settings != null) { container.Register(new InstanceBinding <CharacterSettings>(settings)); } }
/// <summary> /// Registers a generator to the resource container with all of the implemented interfaces by the type of resource then generator creates. /// </summary> /// <param name="container">The container with resources.</param> /// <param name="generator">The generator to bind to the container.</param> /// <typeparam name="T">Type of value the generator provides when requesting an instance.</typeparam> public static void RegisterGeneratorWithInterfaces <T>(this IDependencyContainer container, Func <T> generator) { container.ThrowIfNull(nameof(container)); container.RegisterWithInterfaces <T>(new GeneratorBinding <T>(generator)); }
/// <summary> /// Registers an instance along with all of its implemented interfaces to the resource container. /// </summary> /// <param name="container">The container with resources.</param> /// <param name="instance">Instance resource to bind to the container.</param> /// <typeparam name="T">Type of the instance being bound.</typeparam> public static void RegisterInstanceWithInterfaces <T>(this IDependencyContainer container, T instance) { container.ThrowIfNull(nameof(container)); container.RegisterWithInterfaces <T>(new InstanceBinding <T>(instance)); }