internal NameTransformScopeArgConditionCopyNonLazyBinder FromComponentInNewPrefabResource( string resourcePath, GameObjectCreationParameters gameObjectInfo) { BindingUtil.AssertIsValidResourcePath(resourcePath); BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); BindInfo.RequireExplicitScope = true; SubFinalizer = new PrefabResourceBindingFinalizer( BindInfo, gameObjectInfo, resourcePath, (contractType, instantiator) => new GetFromPrefabComponentProvider(contractType, instantiator)); return(new NameTransformScopeArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo)); }
public ScopeArgConditionCopyNonLazyBinder FromComponentSibling() { BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); return(FromMethodMultiple((ctx) => { Assert.That(ctx.ObjectType.DerivesFromOrEqual <MonoBehaviour>()); Assert.IsNotNull(ctx.ObjectInstance); return ((MonoBehaviour)ctx.ObjectInstance).GetComponents <TContract>() .Where(x => !ReferenceEquals(x, ctx.ObjectInstance)); })); }
public NameTransformConditionCopyNonLazyBinder FromComponentInNewPrefabResource(string resourcePath) { BindingUtil.AssertIsValidResourcePath(resourcePath); BindingUtil.AssertIsInterfaceOrComponent(ContractType); var gameObjectInfo = new GameObjectCreationParameters(); ProviderFunc = (container) => new GetFromPrefabComponentProvider( ContractType, new PrefabInstantiator( container, gameObjectInfo, ContractType, new List <TypeValuePair>(), new PrefabProviderResource(resourcePath))); return(new NameTransformConditionCopyNonLazyBinder(BindInfo, gameObjectInfo)); }
public ConditionCopyNonLazyBinder FromComponentInHierarchy() { BindingUtil.AssertIsInterfaceOrComponent(ContractType); return(FromMethod((container) => { var matches = container.Resolve <Context>().GetRootGameObjects() .SelectMany(x => x.GetComponentsInChildren <TContract>()).ToList(); Assert.That(!matches.IsEmpty(), "Found zero matches when looking up type '{0}' using FromComponentInHierarchy for factory", ContractType); Assert.That(matches.Count() == 1, "Found multiple matches when looking up type '{0}' using FromComponentInHierarchy for factory. Only expected to find one!", ContractType); return matches.Single(); })); }
public ScopeArgConditionCopyNonLazyBinder FromComponentInHierarchy( Func <TContract, bool> predicate = null, bool includeInactive = false) { BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); return(FromMethodMultiple((ctx) => { var res = ctx.Container.Resolve <Context>().GetRootGameObjects() .SelectMany(x => x.GetComponentsInChildren <TContract>(includeInactive)) .Where(x => !ReferenceEquals(x, ctx.ObjectInstance)); if (predicate != null) { res = res.Where(predicate); } return res; })); }
public ScopeArgConditionCopyNonLazyBinder FromComponentInParents(bool excludeSelf = false) { BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); return(FromMethodMultiple((ctx) => { Assert.That(ctx.ObjectType.DerivesFromOrEqual <MonoBehaviour>()); Assert.IsNotNull(ctx.ObjectInstance); var res = ((MonoBehaviour)ctx.ObjectInstance).GetComponentsInParent <TContract>() .Where(x => !ReferenceEquals(x, ctx.ObjectInstance)); if (excludeSelf) { res = res.Where(x => (x as Component).gameObject != (ctx.ObjectInstance as Component).gameObject); } return res; })); }