Пример #1
0
        public void CreateDifferentRasteriserStatesWithNinjectUsingNamedBindings()
        {
            //Given
            SharpDX.Toolkit.Graphics.GraphicsDevice device = SharpDX.Toolkit.Graphics.GraphicsDevice.New(DeviceCreationFlags.Debug);
            IKernel kernal = new StandardKernel();

            kernal.Bind <SharpDXGraphicsDevice>().ToSelf().InSingletonScope();
            kernal.Bind <DefaultRasteriserState>().ToSelf().InSingletonScope();
            kernal.Bind <ShadowBiasedDepthRasteriserState>().ToSelf().InSingletonScope();

            kernal.Bind <FearGraphicsDevice>().ToConstant <SharpDXGraphicsDevice>(new SharpDXGraphicsDevice(GraphicsDevice.New(DeviceCreationFlags.Debug)));
            kernal.Bind <RasteriserState>().To <DefaultRasteriserState>().Named("Default");
            kernal.Bind <RasteriserState>().To <ShadowBiasedDepthRasteriserState>().Named("ShadowBiasedDepth");

            //When
            RasteriserState state = kernal.Get <RasteriserState>("Default");

            //Then
            Assert.IsTrue(state.GetType() == typeof(DefaultRasteriserState));

            //When
            state = kernal.Get <RasteriserState>("ShadowBiasedDepth");

            //Then
            Assert.IsTrue(state.GetType() == typeof(ShadowBiasedDepthRasteriserState));
        }
Пример #2
0
        public void CreateRasteriserStateWithNinject()
        {
            //Given
            IKernel kernal = new StandardKernel();

            kernal.Bind <SharpDXGraphicsDevice>().ToSelf().InSingletonScope();
            kernal.Bind <DefaultRasteriserState>().ToSelf().InSingletonScope();

            kernal.Bind <FearGraphicsDevice>().ToConstant <SharpDXGraphicsDevice>(new SharpDXGraphicsDevice(GraphicsDevice.New(DeviceCreationFlags.Debug)));
            kernal.Bind <RasteriserState>().To <DefaultRasteriserState>();

            //When
            RasteriserState state = kernal.Get <RasteriserState>();

            //Then
            Assert.IsTrue(state.GetType() == typeof(DefaultRasteriserState));
        }