示例#1
0
 public void Listen(ModestTree.Util.Action <TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> listener)
 {
     Assert.That(!_listeners.Contains(listener),
                 () => "Tried to add method '{0}' to signal '{1}' but it has already been added"
                 .Fmt(MethodToString(listener), this.GetType().Name));
     _listeners.Add(listener);
 }
示例#2
0
        public void Unlisten(ModestTree.Util.Action <TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> listener)
        {
            bool success = _listeners.Remove(listener);

            Assert.That(success,
                        () => "Tried to remove method '{0}' from signal '{1}' without adding it first"
                        .Fmt(MethodToString(listener), this.GetType().Name));
        }
示例#3
0
        static string MethodToString(ModestTree.Util.Action <TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> action)
        {
#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR
            return(action.ToString());
#else
            return("{0}.{1}".Fmt(action.Method.DeclaringType.Name(), action.Method.Name));
#endif
        }
示例#4
0
        public ConditionBinder ByMethod(ModestTree.Util.Action <DiContainer, TParam1, TParam2, TParam3, TParam4> installerMethod)
        {
            SubFinalizer = CreateFinalizer(
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByMethod <TParam1, TParam2, TParam3, TParam4>(
                        container, installerMethod)));

            return(new ConditionBinder(BindInfo));
        }
示例#5
0
        public ConditionCopyNonLazyBinder ByMethod(ModestTree.Util.Action <DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> installerMethod)
        {
            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByMethod <TParam1, TParam2, TParam3, TParam4, TParam5>(
                        container, installerMethod));

            return(new ConditionCopyNonLazyBinder(BindInfo));
        }
示例#6
0
        // AsSingle / AsCached / etc. don't make sense in this case so just return ConditionBinder
        public ConditionBinder ToMethod(ModestTree.Util.Action <TParam1, TParam2, TParam3, TParam4, TParam5> action)
        {
            // Create the command class once and re-use it everywhere
            Finalizer = new SingleProviderBindingFinalizer(
                BindInfo, new CachedProvider(
                    new TransientProvider(
                        typeof(TCommand), Container,
                        InjectUtil.CreateArgListExplicit(action), null)));

            return(new ConditionBinder(BindInfo));
        }
示例#7
0
        public ConditionCopyNonLazyBinder ByMethod(
#if !NET_4_6
            ModestTree.Util.
#endif
            Action <DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> installerMethod)
        {
            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByMethod <TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10>(container, installerMethod), false);

            return(new ConditionCopyNonLazyBinder(BindInfo));
        }
示例#8
0
        public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod(
#if !NET_4_6
            ModestTree.Util.
#endif
            Action <DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> installerMethod)
        {
            var gameObjectInfo = new GameObjectCreationParameters();

            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByNewGameObjectMethod <TParam1, TParam2, TParam3, TParam4, TParam5>(
                        container, gameObjectInfo, installerMethod), false);

            return(new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo));
        }
示例#9
0
        public ScopeConcreteIdArgConditionCopyNonLazyBinder ByMethod(
#if !NET_4_6
            ModestTree.Util.
#endif
            Action <DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> installerMethod)
        {
            var subcontainerBindInfo = new SubContainerCreatorBindInfo();

            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByMethod <TParam1, TParam2, TParam3, TParam4, TParam5>(
                        container, subcontainerBindInfo, installerMethod), false);

            return(new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo));
        }
示例#10
0
        public NameTransformConditionCopyNonLazyBinder ByNewPrefabResourceMethod(
            string resourcePath, ModestTree.Util.Action <DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> installerMethod)
        {
            BindingUtil.AssertIsValidResourcePath(resourcePath);

            var gameObjectInfo = new GameObjectCreationParameters();

            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByNewPrefabMethod <TParam1, TParam2, TParam3, TParam4, TParam5>(
                        container,
                        new PrefabProviderResource(resourcePath),
                        gameObjectInfo, installerMethod));

            return(new NameTransformConditionCopyNonLazyBinder(BindInfo, gameObjectInfo));
        }
        public NameTransformConditionCopyNonLazyBinder ByNewPrefabMethod(
            UnityEngine.Object prefab, ModestTree.Util.Action <DiContainer, TParam1, TParam2, TParam3, TParam4> installerMethod)
        {
            BindingUtil.AssertIsValidPrefab(prefab);

            var gameObjectInfo = new GameObjectCreationParameters();

            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByNewPrefabMethod <TParam1, TParam2, TParam3, TParam4>(
                        container,
                        new PrefabProvider(prefab),
                        gameObjectInfo, installerMethod));

            return(new NameTransformConditionCopyNonLazyBinder(BindInfo, gameObjectInfo));
        }
示例#12
0
        public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod(
            Func <InjectContext, UnityEngine.Object> prefabGetter,
#if !NET_4_6 && !NET_STANDARD_2_0
            ModestTree.Util.
#endif
            Action <DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> installerMethod)
        {
            var gameObjectInfo = new GameObjectCreationParameters();

            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByNewPrefabMethod <TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10>(container,
                                                                                                                                                         new PrefabProviderCustom(prefabGetter),
                                                                                                                                                         gameObjectInfo, installerMethod), false);

            return(new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo));
        }
示例#13
0
        ByMethod(
#if !NET_4_6
            ModestTree.Util.
#endif
            Action <DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> installerMethod)
        {
            var subcontainerBindInfo = new SubContainerCreatorBindInfo();

            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByMethod <TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10>(
                        container, subcontainerBindInfo, installerMethod), false);

#if NOT_UNITY3D
            return(new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo));
#else
            return(new DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder(subcontainerBindInfo, BindInfo));
#endif
        }
示例#14
0
        public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod(
            string resourcePath,
#if !NET_4_6 && !NET_STANDARD_2_0
            ModestTree.Util.
#endif
            Action <DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> installerMethod)
        {
            BindingUtil.AssertIsValidResourcePath(resourcePath);

            var gameObjectInfo = new GameObjectCreationParameters();

            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByNewPrefabMethod <TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10>(container,
                                                                                                                                                         new PrefabProviderResource(resourcePath),
                                                                                                                                                         gameObjectInfo, installerMethod), false);

            return(new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo));
        }
示例#15
0
        public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod(
            UnityEngine.Object prefab,
#if !NET_4_6 && !NET_STANDARD_2_0
            ModestTree.Util.
#endif
            Action <DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> installerMethod)
        {
            BindingUtil.AssertIsValidPrefab(prefab);

            var gameObjectInfo = new GameObjectCreationParameters();

            ProviderFunc =
                (container) => new SubContainerDependencyProvider(
                    ContractType, SubIdentifier,
                    new SubContainerCreatorByNewPrefabMethod <TParam1, TParam2, TParam3, TParam4, TParam5>(
                        container,
                        new PrefabProvider(prefab),
                        gameObjectInfo, installerMethod), false);

            return(new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo));
        }
示例#16
0
        public static string ToDebugString <TParam1, TParam2, TParam3, TParam4, TParam5, TParam6>(this ModestTree.Util.Action <TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> action)
        {
#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR
            return(action.ToString());
#else
            return(action.Method.ToDebugString());
#endif
        }