From ced3d03bdb3ce866d832e03fb212865140905a9a Mon Sep 17 00:00:00 2001 From: Thomas Leyh Date: Sun, 24 Jul 2016 08:14:18 +0200 Subject: Add project files. --- V3/Bindings.cs | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 V3/Bindings.cs (limited to 'V3/Bindings.cs') diff --git a/V3/Bindings.cs b/V3/Bindings.cs new file mode 100644 index 0000000..cc9b193 --- /dev/null +++ b/V3/Bindings.cs @@ -0,0 +1,75 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Ninject.Extensions.Factory; +using Ninject.Modules; +using V3.AI; +using V3.AI.Internal; +using V3.Camera; +using V3.Data; +using V3.Data.Internal; +using V3.Effects; +using V3.Input; +using V3.Input.Internal; +using V3.Map; +using V3.Screens; +using V3.Objects; +using V3.Widgets; + +namespace V3 +{ + /// + /// Defines the bindings of constants, factories and singletons for the + /// Ninject dependency injection framework. + /// + public sealed class Bindings : NinjectModule + { + private readonly V3Game mGame; + private readonly GraphicsDeviceManager mGraphicsDeviceManager; + + /// + /// Creates a new Bindings instance for the given game and graphics + /// device manager. + /// + /// the game that uses this instance + /// the graphics device manager + /// instance to use in this instance + public Bindings(V3Game game, GraphicsDeviceManager graphicsDeviceManager) + { + mGame = game; + mGraphicsDeviceManager = graphicsDeviceManager; + } + + public override void Load() + { + // constants + Bind().ToConstant(mGame.Content); + Bind().ToConstant(mGame); + Bind().ToConstant(mGraphicsDeviceManager); + + // factories + Bind().ToFactory(); + Bind().ToFactory(); + Bind().ToFactory(); + Bind().ToFactory(); + Bind().ToFactory(); + + // singletons + Bind().To().InSingletonScope(); + Bind().To().InSingletonScope(); + Bind().To().InSingletonScope(); + Bind().To().InSingletonScope(); + Bind().ToSelf().InSingletonScope(); + Bind().To().InSingletonScope(); + Bind().To().InSingletonScope(); + Bind().ToSelf().InSingletonScope(); + Bind().ToSelf().InSingletonScope(); + Bind().To().InSingletonScope(); + Bind().ToSelf().InSingletonScope(); + + // regular bindings + Bind().To(); + Bind().To(); + Bind().To(); + } + } +} -- cgit v1.2.1