예제 #1
0
	public static Game NewGame(IBindingContext context)
	{
		WorldLogicCoordinateTransform transformer = new WorldLogicCoordinateTransform(0.32f,10,10);
		var boardView = context.Get<BoardView> (InnerBindingNames.Empty,10,10,transformer);

		return new Game(boardView);
	}
예제 #2
0
        public void NamedBindingDifferentNameError()
        {
            IBindingContext context = TestsFactory.BindingContext();

            context.Bind <int>("foo").To(() => 45);

            Assert.Throws <BindingNotFound>(() => context.Get <int>("notFoo"));
        }
예제 #3
0
        public void BindingSimpleInt()
        {
            IBindingContext context = TestsFactory.BindingContext();

            int expected = 45;

            context.Bind <int>().To(() => expected);

            Assert.AreEqual(context.Get <int>(), expected);
        }
예제 #4
0
        public void OneArgumentBindingError()
        {
            //Requires a string to get the int binging

            IBindingContext context = TestsFactory.BindingContext();

            context.Bind <int>().With <string>().To((value) => 45);

            Assert.Throws <BindingNotFound>(() => context.Get <int>());
        }
예제 #5
0
        public void UnsafeNamedBinding()
        {
            IBindingContext context = TestsFactory.BindingContext();

            System.Func <int> func    = () => 45;
            IBinding          binding = new Binding(func);

            context.Unsafe.Bind("name", typeof(int)).To(binding);

            Assert.AreEqual(context.Get <int>("name"), 45);
        }
예제 #6
0
	void Start()
	{
		DontDestroyOnLoad (gameObject);

		var bindingFinder = new ReflectiveBindingFinder (GetType ().Assembly);

		m_masterContext = new ReflectiveBindingContextFactory (bindingFinder).CreateContext();

		m_masterContext.Get<Game> ();

	}
예제 #7
0
        public void NamedBindingInt()
        {
            IBindingContext context = TestsFactory.BindingContext();

            int    expected    = 45;
            string bindingName = "foo";

            context.Bind <int>(bindingName).To(() => expected);

            Assert.AreEqual(context.Get <int>(bindingName), expected);
        }
예제 #8
0
        public void OneArgumentBinding()
        {
            IBindingContext context = TestsFactory.BindingContext();

            context.Bind <int>().With <string>().To((strParam) => 45);

            context.Bind <string>().To(() => "uhul");

            int ret = context.Get <int>();

            Assert.AreEqual(ret, 45);
        }
예제 #9
0
        public void TwoArgumentBinding()
        {
            IBindingContext context = TestsFactory.BindingContext();

            context.Bind <int>().With <string>().With <float>().To((str, flt) => 45);

            context.Bind <string>().To(() => "uhul");

            context.Bind <float>().To(() => 3.0f);

            int ret = context.Get <int>();

            Assert.AreEqual(ret, 45);
        }
예제 #10
0
        public void OneCorrectArgumentBinding()
        {
            IBindingContext context = TestsFactory.BindingContext();

            string parameter = "";

            context.Bind <int>().With <string>().To((value) => { parameter = value; return(45); });

            context.Bind <string>().To(() => "uhul");

            context.Get <int>();

            Assert.AreEqual(parameter, "uhul");
        }
예제 #11
0
        public void OneArgumentNamedBinding()
        {
            IBindingContext context = TestsFactory.BindingContext();

            int expected = 45;

            context.Bind <int>().With <string>("MyText").To((value) => expected);

            context.Bind <string>("MyText").To(() => "uhul");

            int ret = context.Get <int>();

            Assert.AreEqual(ret, expected);
        }
예제 #12
0
    // Use this for initialization
    void Start()
    {
        var assembly = Assembly.GetAssembly(typeof(Bootstrap));
        var provider = new EasyInject.Engine.Runtime.ReflectiveBindingFinder(true, new Assembly[] { assembly });
        var factory  = new EasyInject.Engine.Runtime.ReflectiveBindingContextFactory(provider);

        m_context = factory.CreateContext();

        //var up = UniRx.Observable.EveryUpdate().Where((u)=> Input.GetKeyDown(KeyCode.KeypadPlus)).Select((u)=> true);
        //var down = UniRx.Observable.EveryUpdate().Where((u) => Input.GetKeyDown(KeyCode.KeypadMinus)).Select((u) => false);

        // m_context.Get<Turret>();

        m_context.Get <Turret>(InnerBindingNames.Empty, Vector2.zero);
    }
예제 #13
0
        public void UnsafePartialBinding()
        {
            IBindingContext     context     = TestsFactory.BindingContext();
            IBindingRequirement requirement = BindingRequirements.Instance.With <float>();

            context.Bind <float>().To(() => 0.1f);
            int extra = -1;

            System.Func <float, int, int> func = (bindinded, nonBinded) => { extra = nonBinded; return(45); };

            IBinding binding = new Binding(func, requirement);

            context.Unsafe.Bind(typeof(int)).To(binding);

            context.Get <int>(InnerBindingNames.Empty, 32);

            Assert.AreEqual(32, extra);
        }
예제 #14
0
        public void BindingSimpleIntError()
        {
            IBindingContext context = TestsFactory.BindingContext();

            Assert.Throws <BindingNotFound>(() => context.Get <int>());
        }
 static public T Get <T>(this IBindingContext me, object name, params object[] extras)
 {
     return(me.Get <T>(new BindingName(name), extras));
 }
예제 #16
0
        public void NamedBindingIntError()
        {
            IBindingContext context = TestsFactory.BindingContext();

            Assert.Throws <BindingNotFound>(() => context.Get <int>("foo"));
        }
예제 #17
0
 public T TypedGet <T> (IBindingContext context)
 {
     return(context.Get <T>());
 }
예제 #18
0
 public T TypedInterfaceGet <T> (IBindingContext context) where T : ITestInterface
 {
     return(context.Get <T>());
 }