Exemplo n.º 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();
    }
Exemplo n.º 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);
        }
Exemplo n.º 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");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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
                });
            }
        }
Exemplo n.º 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");
        }
Exemplo n.º 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");
 }
Exemplo n.º 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");
 }
Exemplo n.º 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");
        }
Exemplo n.º 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;
 }
Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
    }
Exemplo n.º 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);
        }
    }
Exemplo n.º 20
0
 public void When(BindingCondition condition)
 {
     _provider.SetCondition(condition);
 }
 public CopyNonLazyBinder When(BindingCondition condition)
 {
     BindInfo.Condition = condition;
     return(this);
 }
Exemplo n.º 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));
 }
Exemplo n.º 23
0
 public ProviderInfo(IProvider provider, BindingCondition condition)
 {
     Provider  = provider;
     Condition = condition;
 }
Exemplo n.º 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);
        }
Exemplo n.º 25
0
 public void When(BindingCondition condition)
 {
     _provider.Condition = condition;
 }
Exemplo n.º 26
0
 public void SetCondition(BindingCondition condition)
 {
     _condition = condition;
 }
Exemplo n.º 27
0
 public CopyIntoSubContainersBinder When(BindingCondition condition)
 {
     BindInfo.Condition = condition;
     return(this);
 }
Exemplo n.º 28
0
 public void SetCondition(BindingCondition condition)
 {
     _condition = condition;
 }
Exemplo n.º 29
0
 public IdentifierSetter When(BindingCondition condition)
 {
     _provider.Condition = condition;
     return(new IdentifierSetter(_provider));
 }
Exemplo n.º 30
0
 public InheritInSubContainersBinder When(BindingCondition condition)
 {
     BindInfo.Condition = condition;
     return(this);
 }