示例#1
0
    public override void InstallBindings()
    {
        BindingCondition bindCond = (x) => x.Container == Container;

        Container.BindMonoContextPool <ProjectileFacade, ProjectileSpawnParameters, ProjectileFacade.Factory, ProjectilePool>
            (Identifiers.Bullet, 10, _projectilePrefab, "Projectiles", bindCond);

        Container.BindMonoContextPool <ProjectileFacade, ProjectileSpawnParameters, ProjectileFacade.Factory, ProjectilePool>
            (Identifiers.Ray, 10, _rayProjectilePrefab, "RayProjectiles", bindCond);

        Container.BindMonoPrefabPool <LineVFX, LineVFXSpawnParameters, LineVFX.Factory, LineVFXPool>
            (Identifiers.Ray, 10, _lineVFX, "LineVFXs");

        Container.BindMonoPrefabPool <ExplosionVFX, Vector3, ExplosionVFX.Factory, ExplosionVFXPool>
            (Identifiers.Explosion, 10, _explosionVFX, "ExplosionVFXs");

        Container.BindMonoContextPool <ItemPickup, PickupSpawnParameters, ItemPickup.Factory, PickupPool>
            (Identifiers.Inventory, 10, _pickupPrefab, "Pickups");

        Container.BindMonoPrefabPool <CharacterFacade, CharacterSpawnParameters, CharacterFacade.Factory, CharacterPool>
            (Identifiers.AI, 10, _AIPrefab, "AI");

        Container.BindMonoPrefabPool <CharacterFacade, CharacterSpawnParameters, CharacterFacade.Factory, CharacterPool>
            (Identifiers.Network, 4, _networkedCharacterPrefab, "Characters");

        Container.BindMonoPrefabPool <CharacterFacade, CharacterSpawnParameters, CharacterFacade.Factory, CharacterPool>
            (Identifiers.Player, 1, _playerPrefab, "Players");

        Container.Bind <IFactory <ProjectileSpawnParameters, ProjectileFacade[]> >().WithId(Identifiers.Bullet).To <RigidProjectileMultiFactory>().AsSingle();
        Container.Bind <IFactory <ProjectileSpawnParameters, ProjectileFacade[]> >().WithId(Identifiers.Ray).To <RayProjectileMultiFactory>().AsSingle();
    }
示例#2
0
        public void BindingConditionConstructor()
        {
            tlog.Debug(tag, $"BindingConditionConstructor START");
            BindingCondition mb = new BindingCondition();

            Assert.IsNotNull(mb, "Should not be null");
            tlog.Debug(tag, $"BindingConditionConstructor END");
        }
        /// <summary>
        /// Conditions the binding to be injected only if BindingConditionEvaluator returns true.
        /// </summary>
        /// <param name="condition">Condition.</param>
        /// <returns>The current binding condition.</returns>
        public IBindingConditionFactory When(BindingCondition condition)
        {
            for (var index = 0; index < this.bindingConditionFactories.Length; index++)
            {
                this.bindingConditionFactories[index].When(condition);
            }

            return(this);
        }
示例#4
0
        public void IsSealedTest2()
        {
            tlog.Debug(tag, $"IsSealedTest2 START");
            BindingCondition mb = new BindingCondition();

            Assert.IsNotNull(mb, "Should not be null");
            mb.IsSealed = true;
            Assert.AreEqual(true, mb.IsSealed, "Should be equal");
            Assert.Throws <InvalidOperationException>(() => mb.IsSealed = false);
            tlog.Debug(tag, $"IsSealedTest2 END");
        }
示例#5
0
        public void BindingTest()
        {
            tlog.Debug(tag, $"BindingTest START");
            BindingCondition mb = new BindingCondition();

            Assert.IsNotNull(mb, "Should not be null");
            var ret = mb.Binding; //null

            Assert.IsNull(ret, "Should be null");
            mb.Binding = ret;
            tlog.Debug(tag, $"BindingTest END");
        }
示例#6
0
        public void BindingTest3()
        {
            tlog.Debug(tag, $"BindingTest3 START");
            BindingCondition mb = new BindingCondition();

            Assert.IsNotNull(mb, "Should not be null");
            var b = new Binding.Binding();

            mb.IsSealed = true;
            Assert.Throws <InvalidOperationException>(() => mb.Binding = b);
            tlog.Debug(tag, $"BindingTest3 END");
        }
示例#7
0
        public void IsSealedTest()
        {
            tlog.Debug(tag, $"IsSealedTest START");
            BindingCondition mb = new BindingCondition();

            Assert.IsNotNull(mb, "Should not be null");
            var ret = mb.IsSealed;

            Assert.AreEqual(false, ret, "Should be equal");
            mb.IsSealed = ret;
            tlog.Debug(tag, $"IsSealedTest END");
        }
示例#8
0
        public void ConditionChangedTest2()
        {
            tlog.Debug(tag, $"ConditionChangedTest2 START");
            BindingCondition mb = new BindingCondition();

            Assert.IsNotNull(mb, "Should not be null");
            var ac = (Action <BindableObject, bool, bool>)((bindable, b, c) => throw new Exception());

            mb.ConditionChanged = ac;

            tlog.Debug(tag, $"ConditionChangedTest2 END");
        }
示例#9
0
        public void ValueTest3()
        {
            tlog.Debug(tag, $"ValueTest3 START");

            BindingCondition mb = new BindingCondition();

            Assert.IsNotNull(mb, "Should not be null");
            var ret = new View();

            mb.IsSealed = true;
            Assert.Throws <InvalidOperationException>(() => mb.Value = ret);

            tlog.Debug(tag, $"ValueTest3 END");
        }
示例#10
0
        public void BindingTest2()
        {
            tlog.Debug(tag, $"BindingTest2 START");
            BindingCondition mb = new BindingCondition();

            Assert.IsNotNull(mb, "Should not be null");
            var b = new Binding.Binding();

            mb.Binding = b;
            var ret = mb.Binding; //null

            Assert.AreEqual(b, ret, "Should be equal");

            tlog.Debug(tag, $"BindingTest2 END");
        }
示例#11
0
        public void RegisterProvider(BindingId bindingId, BindingCondition condition, IProvider provider)
        {
            var info = new ProviderInfo(provider, condition);

            if (providers.ContainsKey(bindingId))
            {
                providers[bindingId].Add(info);
            }
            else
            {
                providers.Add(bindingId, new List <ProviderInfo>()
                {
                    info
                });
            }
        }
示例#12
0
        public void GetStateTest()
        {
            tlog.Debug(tag, $"GetStateTest START");
            try {
                BindingCondition mb = new BindingCondition();
                Assert.IsNotNull(mb, "Should not be null");
                var ret = mb.GetState(new View());
                Assert.AreEqual(true, ret, "Should be equal");
                //Assert.Throws<ArgumentNullException>(() => mb.AttachedTo(null));
            }
            catch (Exception e)
            {
                Assert.Fail("Should not thow exception: " + e.Message);
            }

            tlog.Debug(tag, $"GetStateTest END");
        }
示例#13
0
 public void ValueTest2()
 {
     tlog.Debug(tag, $"ValueTest2 START");
     try
     {
         BindingCondition mb = new BindingCondition();
         Assert.IsNotNull(mb, "Should not be null");
         var ret = new View();
         mb.Value = ret;
         Assert.AreEqual(ret, mb.Value, "Should be equal");
     }
     catch (Exception e)
     {
         Assert.Fail("Should not thow exception: " + e.Message);
     }
     tlog.Debug(tag, $"ValueTest2 END");
 }
示例#14
0
 public void ValueTest()
 {
     tlog.Debug(tag, $"ValueTest START");
     try
     {
         BindingCondition mb = new BindingCondition();
         Assert.IsNotNull(mb, "Should not be null");
         var ret = mb.Value;
         Assert.IsNotNull(mb, "Should not be null");
         mb.Value = ret;
     }
     catch (Exception e)
     {
         Assert.Fail("Should not thow exception: " + e.Message);
     }
     tlog.Debug(tag, $"ValueTest END");
 }
示例#15
0
        public void TearDownTest()
        {
            tlog.Debug(tag, $"TearDownTest START");
            try
            {
                BindingCondition mb = new BindingCondition();
                Assert.IsNotNull(mb, "Should not be null");
                mb.TearDown(new View());
                //Assert.Throws<ArgumentNullException>(() => mb.AttachedTo(null));
            }
            catch (Exception e)
            {
                Assert.Fail("Should not thow exception: " + e.Message);
            }

            tlog.Debug(tag, $"TearDownTest END");
        }
示例#16
0
 public void Reset()
 {
     MarkAsCreationBinding = true;
     MarkAsUniqueSingleton = false;
     ConcreteIdentifier    = null;
     SaveProvider          = false;
     OnlyBindIfNotBound    = false;
     RequireExplicitScope  = false;
     Identifier            = null;
     ContractTypes.Clear();
     BindingInheritanceMethod = BindingInheritanceMethods.None;
     InvalidBindResponse      = InvalidBindResponses.Assert;
     NonLazy     = false;
     Condition   = null;
     ToChoice    = ToChoices.Self;
     ContextInfo = null;
     ToTypes.Clear();
     Scope = ScopeTypes.Unset;
     Arguments.Clear();
     InstantiatedCallback = null;
 }
示例#17
0
        protected override void Invoke(SwitchGroupLayout sender)
        {
            MultiTrigger     _trigger   = new MultiTrigger(typeof(SwitchGroupLayout));
            BindingCondition _condition = new BindingCondition()
            {
            };
            List <Switch> lista = new List <Switch>();
            var           _this = sender as Layout <View>;

            foreach (var view in _this.Children)
            {
                if (view is Switch && view != sender)
                {
                    /*
                     * _trigger.Conditions.Add(new BindingCondition() {
                     *
                     *  Binding:((Switch)view).BindingContext.ToString(),source:"IsToggled"
                     *
                     * });
                     * //lista.Add((Switch)view);*/
                }
            }
            //_trigger.Conditions.Add();
        }
示例#18
0
    public static void BindMonoPrefabPool <T, TArgs, TFactory, TPool>(this DiContainer Container, Identifiers id, int size, T prefab, Transform parentTransform, BindingCondition cond = null)
        where T : MonoBehaviour, IPoolable <TArgs, IMemoryPool>
        where TFactory : PlaceholderFactory <TArgs, T>
        where TPool : MonoPoolableMemoryPool <TArgs, IMemoryPool, T>
    {
        var bind =
            Container.BindFactory <TArgs, T, TFactory>().
            WithId(id).
            FromPoolableMemoryPool <TArgs, T, TPool>
                (x => x.WithInitialSize(size).
                ExpandByDoubling().
                FromComponentInNewPrefab(prefab).
                UnderTransform(parentTransform));

        if (cond != null)
        {
            bind.When(cond);
        }
    }
示例#19
0
    public static void BindMonoContextPool <T, TArgs, TFactory, TPool>(this DiContainer Container, Identifiers id, int size, GameObject prefab, string transformGroupName, BindingCondition cond = null)
        where T : IComponent, IPoolable <TArgs, IMemoryPool>
        where TFactory : PlaceholderFactory <TArgs, T>
        where TPool : ContextGameObjectMemoryPool <TArgs, IMemoryPool, T>
    {
        var bind =
            Container.BindFactory <TArgs, T, TFactory>().
            WithId(id).
            FromPoolableMemoryPool <TArgs, T, TPool>
                (x => x.WithInitialSize(size).
                ExpandByDoubling().
                FromSubContainerResolve().
                ByNewContextPrefab(prefab).
                UnderTransformGroup(transformGroupName));

        if (cond != null)
        {
            bind.When(cond);
        }
    }
 public void When(BindingCondition condition)
 {
     _provider.SetCondition(condition);
 }
 public CopyNonLazyBinder When(BindingCondition condition)
 {
     BindInfo.Condition = condition;
     return(this);
 }
示例#22
0
 /// <summary>
 /// Conditions the binding to be injected only if BindingConditionEvaluator returns true.
 /// </summary>
 /// <param name="condition">Condition.</param>
 /// <returns>The current binding condition.</returns>
 public IBindingConditionFactory When(BindingCondition condition)
 {
     return(this.bindingConditionFactory.When(condition));
 }
示例#23
0
 public ProviderInfo(IProvider provider, BindingCondition condition)
 {
     Provider  = provider;
     Condition = condition;
 }
示例#24
0
        /// <summary>
        /// Conditions the binding to be injected only if BindingConditionEvaluator returns true.
        /// </summary>
        /// <param name="condition">Condition.</param>
        /// <returns>The current binding condition.</returns>
        public IBindingConditionFactory When(BindingCondition condition)
        {
            this.binding.condition = condition;

            return(this);
        }
示例#25
0
 public void When(BindingCondition condition)
 {
     _provider.Condition = condition;
 }
示例#26
0
 public void SetCondition(BindingCondition condition)
 {
     _condition = condition;
 }
示例#27
0
 public CopyIntoSubContainersBinder When(BindingCondition condition)
 {
     BindInfo.Condition = condition;
     return(this);
 }
示例#28
0
 public void SetCondition(BindingCondition condition)
 {
     _condition = condition;
 }
 public IdentifierSetter When(BindingCondition condition)
 {
     _provider.Condition = condition;
     return(new IdentifierSetter(_provider));
 }
示例#30
0
 public InheritInSubContainersBinder When(BindingCondition condition)
 {
     BindInfo.Condition = condition;
     return(this);
 }