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(); }
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); }
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"); }
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"); }
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"); }
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"); }
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"); }
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"); }
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"); }
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 }); } }
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"); }
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"); }
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"); }
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"); }
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; }
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(); }
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); } }
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); }
/// <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)); }
public ProviderInfo(IProvider provider, BindingCondition condition) { Provider = provider; Condition = condition; }
/// <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); }
public void When(BindingCondition condition) { _provider.Condition = condition; }
public void SetCondition(BindingCondition condition) { _condition = condition; }
public CopyIntoSubContainersBinder When(BindingCondition condition) { BindInfo.Condition = condition; return(this); }
public IdentifierSetter When(BindingCondition condition) { _provider.Condition = condition; return(new IdentifierSetter(_provider)); }
public InheritInSubContainersBinder When(BindingCondition condition) { BindInfo.Condition = condition; return(this); }