示例#1
0
        private void SingletoneCreation(MiniocContext context)
        {
            IOrange orange = context.Resolve <IOrange>();

            Assert.That(orange is BlueOrange);
            orange.tag = "my_test_orange";
        }
示例#2
0
            public IMyClass Create(IApple apple, IOrange orange)
            {
                IMyClass myClass = base.CreateInstance(() => Construction.
                                                       ForType <IApple>(apple)
                                                       .AndType <IOrange>(orange)
                                                       );

                return(myClass);
            }
示例#3
0
        public void TestResolvedInstanceHasBindingDescriptor()
        {
            IDIContext context = ContextHelper.CreateContext();

            context.m().Bind <IOrange> (() => new Orange1());

            IOrange          orange = context.Resolve <IOrange> ();
            IDIClosedContext ctx    = orange as IDIClosedContext;

            Assert.IsNotNull(ctx.bindingDescriptor);
        }
示例#4
0
        public void TestResolveObjectWithInvalidatedContext()
        {
            IDIContext context = ContextHelper.CreateContext();

            context.m().Bind <IOrange> (() => new Orange1());

            IOrange          orange = context.Resolve <IOrange> ();
            IDIClosedContext ctx    = orange as IDIClosedContext;

            Assert.IsNotNull(ctx.descriptor.bindingDescriptor);
        }
示例#5
0
        public void TestSingletonPersistance()
        {
            MiniocContext context = new MiniocContext();

            context.s().Bind <IOrange>(() => new BlueOrange());

            SingletoneCreation(context);

            IOrange orange = context.Resolve <IOrange>();

            Assert.AreEqual("my_test_orange", orange.tag);
        }
示例#6
0
        public void SingletoneSameContextTest()
        {
            MiniocContext context = new MiniocContext();

            context.s().Bind <IOrange>(() => new RedOrange());

            IOrange orange1 = context.Resolve <IOrange>();
            IOrange orange2 = context.Resolve <IOrange>();

            Assert.That(orange1 is RedOrange);
            Assert.That(orange2 is RedOrange);

            Assert.AreSame(orange1, orange2);
        }
示例#7
0
        public void MultipleSameContextTest()
        {
            IDIContext context = new MiniocContext();

            context.m().Bind <IOrange>(() => new RedOrange());

            IOrange orange1 = context.Resolve <IOrange>();
            IOrange orange2 = context.Resolve <IOrange>();

            Assert.That(orange1 is RedOrange);
            Assert.That(orange2 is RedOrange);

            Assert.AreNotSame(orange1, orange2);
        }
示例#8
0
    public void Initialize(IOrange orange)
    {
        if (!isInitialize)
        {
            buttonHandlerList = new Dictionary <int, IButtonHandler>();
            _isInitialize     = true;
            this._orange      = orange;
            _isEnable         = false;
            CompleteHide();
            if (onInitialize != null)
            {
                onInitialize(this, new EventArgs());
            }

            log += string.Format("Initialize()\n{0}\n\n", Utilty.CallStack());
        }
    }
示例#9
0
        public void SingletoneFactoryDifferentContextTest()
        {
            IDIContext context1 = new MiniocContext();

            context1.s().Bind <IOrange>(() => new RedOrange());

            IDIContext context2 = new MiniocContext();

            context2.s().Bind <IOrange>(() => new RedOrange());

            IOrange orange1 = context1.Resolve <IOrange>();
            IOrange orange2 = context2.Resolve <IOrange>();

            Assert.That(orange1 is RedOrange);
            Assert.That(orange2 is RedOrange);

            Assert.AreNotSame(orange1, orange2);
        }
示例#10
0
    public void Initialize(IOrange orange, params IButtonHandler[] btns)
    {
        if (!isInitialize)
        {
            buttonHandlerList = new Dictionary <int, IButtonHandler>();
            this._orange      = orange;
            _isInitialize     = true;
            InitializeButton(btns);

            SetEnable(false);
            if (onInitialize != null)
            {
                onInitialize(this, new EventArgs());
            }

            log += string.Format("Initialize()\n{0}\n\n", Utilty.CallStack());
        }
    }
示例#11
0
        public void SingletoneChainedContextTest()
        {
            MiniocContext context1 = new MiniocContext();


            context1.s().Bind <IOrange>(() => new RedOrange());

            MiniocContext context2 = new MiniocContext(context1);

            IOrange orange1 = context1.Resolve <IOrange>();
            IOrange orange2 = context2.Resolve <IOrange>();

            Assert.That(orange1 is RedOrange);
            Assert.That(orange2 is RedOrange);

            Assert.AreSame(orange1, orange2);

            context2.s().Bind <IOrange>(() => new RedOrange());

            orange2 = context2.Resolve <IOrange>();
            Assert.That(orange2 is RedOrange);
            Assert.AreNotSame(orange1, orange2);
        }
示例#12
0
 public Apple(IOrange orange)
 {
     this.orange = orange;
 }
示例#13
0
 protected void InjectionMethod(IOrange orange)
 {
     this.orange = orange;
 }
示例#14
0
 protected void InjectionMethod(IOrange orange, IApple apple)
 {
     this.orange = orange;
     this.apple  = apple;
 }
 public Apple(IOrange orange)
 {
     this.orange = orange;
 }