public static IBindingScope ToPrefab(this IBindingContract contract, GameObject prefab, bool injectHierarchy = true) { Assert.IsNotNull(prefab); Assert.IsTrue(contract.ContractType.Is <GameObject>() || prefab.GetComponent(contract.ContractType) != null); return(contract.ToMethod(c => { var instance = UnityEngine.Object.Instantiate(prefab); if (injectHierarchy) { var components = instance.GetComponentsInChildren <MonoBehaviour>(); for (int i = 0; i < components.Length; i++) { c.Container.Injector.Inject(components[i]); } } if (contract.ContractType.Is <GameObject>()) { return instance; } else { return instance.GetComponent(contract.ContractType); } })); }
public static IBindingScope ToPrefab(this IBindingContract contract, UnityEngine.Object prefab) { Assert.IsNotNull(prefab); Assert.IsTrue(prefab.GetType().Is(contract.ContractType)); return(contract.ToMethod(c => UnityEngine.Object.Instantiate(prefab))); }
public static IBindingCondition ToPool <TContract, TConcrete>(this IBindingContract <TContract> contract, IPool <TConcrete> pool) where TConcrete : class, TContract { return(contract.ToPool(pool)); }
public static IBindingCondition ToPool(this IBindingContract contract, IPool pool) { Assert.IsTrue(pool.Type.Is(contract.ContractType)); return(contract.ToMethod(c => pool.Create()).AsTransient()); }
protected virtual IBindingScope To(IBindingContract contract, Type concreteType) { return contract.To(concreteType); }
protected virtual IBindingScope To(IBindingContract contract, Type concreteType) { return(contract.To(concreteType)); }
protected override IBindingScope To(IBindingContract contract, Type concreteType) { return contract.ToFactory(concreteType); }
public static IBindingScope ToPrefab <TContract, TConcrete>(this IBindingContract <TContract> contract, TConcrete prefab) where TConcrete : UnityEngine.Object, TContract { return(((IBindingContract)contract).ToPrefab(prefab)); }
/// <summary> /// Determines whether the selected item is bindable to the model class T. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="item">The item containing the field with the selected item to bind.</param> /// <param name="fieldId">The id of the field containing the selected item to test.</param> /// <param name="bindingContract">The binding contract to use for testing the selected item.</param> /// <returns><c>true</c> if the selected item is bindable to the model class T; otherwise <c>false</c></returns> public static Boolean IsSelectedItemBindable <T>(this Item item, ID fieldId, IBindingContract bindingContract) where T : class { Item targetItem = item.GetDropLinkSelectedItem(fieldId); return(targetItem != null && targetItem.IsBindable <T>(bindingContract)); }
/// <summary> /// Determines whether the selected item is bindable to the model class T. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="item">The item containing the field with the selected item to bind.</param> /// <param name="fieldId">The id of the field containing the selected item to test.</param> /// <returns><c>true</c> if the selected item is bindable to the model class T; otherwise <c>false</c></returns> public static Boolean IsSelectedItemBindable <T>(this Item item, ID fieldId) where T : class { IBindingContract bindingContract = ModelFactoryService.ResolveModelFactory <T>().BindingContract; return(item.IsSelectedItemBindable <T>(fieldId, bindingContract)); }
/// <summary> /// Determines whether the specified item is bindable to the model class T. /// </summary> /// <typeparam name="T">The model class that the item should be bindable to.</typeparam> /// <param name="item">The item to test.</param> /// <param name="bindingContract">The binding contract to use for testing the item.</param> /// <returns><c>true</c> if the item is bindable to the model class T; otherwise <c>false</c></returns> public static Boolean IsBindable <T>(this Item item, IBindingContract bindingContract) where T : class { return(bindingContract.IsCompliant <T>(item)); }
/// <summary> /// Determines whether the specified item is bindable to the model class T. /// </summary> /// <typeparam name="T">The model class that the item should be bindable to.</typeparam> /// <param name="item">The item to test.</param> /// <returns><c>true</c> if the item is bindable to the model class T; otherwise <c>false</c></returns> public static Boolean IsBindable <T>(this Item item) where T : class { IBindingContract bindingContract = ModelFactoryService.ResolveModelFactory <T>().BindingContract; return(item.IsBindable <T>(bindingContract)); }
/// <summary> /// Determines whether the specified item or one of its ancestors is bindable to the model class T. /// </summary> /// <typeparam name="T">The model class that the item should be bindable to.</typeparam> /// /// <param name="bindingContract">The binding contract to use for testing the item.</param> /// <param name="item">The item to test.</param> /// <returns><c>true</c> if the item or one of its ancestors is bindable to the model class T; otherwise <c>false</c></returns> public static Boolean IsAncestorOrSelfBindable <T>(this Item item, IBindingContract bindingContract) where T : class { return(GetAncestorsAndSelf(item).Any(itm => itm.IsBindable <T>())); }
protected override IBindingScope To(IBindingContract contract, Type concreteType) { return(contract.ToFactory(concreteType)); }