Update Project
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
public interface ISubContainerCreator
|
||||
{
|
||||
DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83273a08f84aa9a48b37fe0b1bae0958
|
||||
timeCreated: 1461708051
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorBindInfo
|
||||
{
|
||||
// Null = means no custom default parent
|
||||
public string DefaultParentName
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public bool CreateKernel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public Type KernelType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d894c838f0dcc34bb38d1311af9ea56
|
||||
timeCreated: 1534923025
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ModestTree;
|
||||
using Zenject.Internal;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByInstaller : ISubContainerCreator
|
||||
{
|
||||
readonly Type _installerType;
|
||||
readonly DiContainer _container;
|
||||
readonly List<TypeValuePair> _extraArgs;
|
||||
readonly SubContainerCreatorBindInfo _containerBindInfo;
|
||||
|
||||
public SubContainerCreatorByInstaller(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
Type installerType,
|
||||
IEnumerable<TypeValuePair> extraArgs)
|
||||
{
|
||||
_installerType = installerType;
|
||||
_container = container;
|
||||
_extraArgs = extraArgs.ToList();
|
||||
_containerBindInfo = containerBindInfo;
|
||||
|
||||
Assert.That(installerType.DerivesFrom<InstallerBase>(),
|
||||
"Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType);
|
||||
}
|
||||
|
||||
public SubContainerCreatorByInstaller(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
Type installerType)
|
||||
: this(container, containerBindInfo, installerType, new List<TypeValuePair>())
|
||||
{
|
||||
}
|
||||
|
||||
public DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
var subContainer = _container.CreateSubContainer();
|
||||
|
||||
SubContainerCreatorUtil.ApplyBindSettings(_containerBindInfo, subContainer);
|
||||
|
||||
var extraArgs = ZenPools.SpawnList<TypeValuePair>();
|
||||
|
||||
extraArgs.AllocFreeAddRange(_extraArgs);
|
||||
extraArgs.AllocFreeAddRange(args);
|
||||
|
||||
var installer = (InstallerBase)subContainer.InstantiateExplicit(
|
||||
_installerType, extraArgs);
|
||||
|
||||
ZenPools.DespawnList(extraArgs);
|
||||
|
||||
installer.InstallBindings();
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
subContainer.ResolveRoots();
|
||||
};
|
||||
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d932bdf1cc240394a94c9fd81dfa9218
|
||||
timeCreated: 1461708054
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using ModestTree;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByInstance : ISubContainerCreator
|
||||
{
|
||||
readonly DiContainer _subcontainer;
|
||||
|
||||
public SubContainerCreatorByInstance(DiContainer subcontainer)
|
||||
{
|
||||
_subcontainer = subcontainer;
|
||||
}
|
||||
|
||||
public DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.That(args.IsEmpty());
|
||||
|
||||
injectAction = null;
|
||||
|
||||
// It is assumed here that the subcontainer has already had ResolveRoots called elsewhere
|
||||
// Since most likely you are adding a subcontainer that is already in a context or
|
||||
// something rather than directly using DiContainer.CreateSubContainer
|
||||
return _subcontainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ea58c024bbd4e846be07059bf23c524
|
||||
timeCreated: 1535189469
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModestTree;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByInstanceGetter : ISubContainerCreator
|
||||
{
|
||||
readonly Func<InjectContext, DiContainer> _subcontainerGetter;
|
||||
|
||||
public SubContainerCreatorByInstanceGetter(
|
||||
Func<InjectContext, DiContainer> subcontainerGetter)
|
||||
{
|
||||
_subcontainerGetter = subcontainerGetter;
|
||||
}
|
||||
|
||||
public DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.That(args.IsEmpty());
|
||||
|
||||
injectAction = null;
|
||||
|
||||
// It is assumed here that the subcontainer has already had ResolveRoots called elsewhere
|
||||
// Since most likely you are adding a subcontainer that is already in a context or
|
||||
// something rather than directly using DiContainer.CreateSubContainer
|
||||
return _subcontainerGetter(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 164cf97cfe8f32441beb85b9b3c05868
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+390
@@ -0,0 +1,390 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModestTree;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
// Zero parameters
|
||||
|
||||
[NoReflectionBaking]
|
||||
public abstract class SubContainerCreatorByMethodBase : ISubContainerCreator
|
||||
{
|
||||
readonly DiContainer _container;
|
||||
readonly SubContainerCreatorBindInfo _containerBindInfo;
|
||||
|
||||
public SubContainerCreatorByMethodBase(
|
||||
DiContainer container, SubContainerCreatorBindInfo containerBindInfo)
|
||||
{
|
||||
_container = container;
|
||||
_containerBindInfo = containerBindInfo;
|
||||
}
|
||||
|
||||
public abstract DiContainer CreateSubContainer(
|
||||
List<TypeValuePair> args, InjectContext context, out Action injectAction);
|
||||
|
||||
protected DiContainer CreateEmptySubContainer()
|
||||
{
|
||||
var subContainer = _container.CreateSubContainer();
|
||||
SubContainerCreatorUtil.ApplyBindSettings(_containerBindInfo, subContainer);
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByMethod : SubContainerCreatorByMethodBase
|
||||
{
|
||||
readonly Action<DiContainer> _installMethod;
|
||||
|
||||
public SubContainerCreatorByMethod(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
Action<DiContainer> installMethod)
|
||||
: base(container, containerBindInfo)
|
||||
{
|
||||
_installMethod = installMethod;
|
||||
}
|
||||
|
||||
public override DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.IsEmpty(args);
|
||||
|
||||
var subContainer = CreateEmptySubContainer();
|
||||
|
||||
_installMethod(subContainer);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
subContainer.ResolveRoots();
|
||||
};
|
||||
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// One parameters
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByMethod<TParam1> : SubContainerCreatorByMethodBase
|
||||
{
|
||||
readonly Action<DiContainer, TParam1> _installMethod;
|
||||
|
||||
public SubContainerCreatorByMethod(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
Action<DiContainer, TParam1> installMethod)
|
||||
: base(container, containerBindInfo)
|
||||
{
|
||||
_installMethod = installMethod;
|
||||
}
|
||||
|
||||
public override DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 1);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
|
||||
var subContainer = CreateEmptySubContainer();
|
||||
|
||||
_installMethod(subContainer, (TParam1)args[0].Value);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
subContainer.ResolveRoots();
|
||||
};
|
||||
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// Two parameters
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByMethod<TParam1, TParam2> : SubContainerCreatorByMethodBase
|
||||
{
|
||||
readonly Action<DiContainer, TParam1, TParam2> _installMethod;
|
||||
|
||||
public SubContainerCreatorByMethod(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
Action<DiContainer, TParam1, TParam2> installMethod)
|
||||
: base(container, containerBindInfo)
|
||||
{
|
||||
_installMethod = installMethod;
|
||||
}
|
||||
|
||||
public override DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 2);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
|
||||
var subContainer = CreateEmptySubContainer();
|
||||
|
||||
_installMethod(
|
||||
subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
subContainer.ResolveRoots();
|
||||
};
|
||||
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// Three parameters
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByMethod<TParam1, TParam2, TParam3> : SubContainerCreatorByMethodBase
|
||||
{
|
||||
readonly Action<DiContainer, TParam1, TParam2, TParam3> _installMethod;
|
||||
|
||||
public SubContainerCreatorByMethod(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
Action<DiContainer, TParam1, TParam2, TParam3> installMethod)
|
||||
: base(container, containerBindInfo)
|
||||
{
|
||||
_installMethod = installMethod;
|
||||
}
|
||||
|
||||
public override DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 3);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
|
||||
var subContainer = CreateEmptySubContainer();
|
||||
|
||||
_installMethod(
|
||||
subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
subContainer.ResolveRoots();
|
||||
};
|
||||
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// Four parameters
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByMethod<TParam1, TParam2, TParam3, TParam4> : SubContainerCreatorByMethodBase
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4> _installMethod;
|
||||
|
||||
public SubContainerCreatorByMethod(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4> installMethod)
|
||||
: base(container, containerBindInfo)
|
||||
{
|
||||
_installMethod = installMethod;
|
||||
}
|
||||
|
||||
public override DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 4);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
|
||||
var subContainer = CreateEmptySubContainer();
|
||||
|
||||
_installMethod(
|
||||
subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
subContainer.ResolveRoots();
|
||||
};
|
||||
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// Five parameters
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByMethod<TParam1, TParam2, TParam3, TParam4, TParam5> : SubContainerCreatorByMethodBase
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> _installMethod;
|
||||
|
||||
public SubContainerCreatorByMethod(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> installMethod)
|
||||
: base(container, containerBindInfo)
|
||||
{
|
||||
_installMethod = installMethod;
|
||||
}
|
||||
|
||||
public override DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 5);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
Assert.That(args[4].Type.DerivesFromOrEqual<TParam5>());
|
||||
|
||||
var subContainer = CreateEmptySubContainer();
|
||||
|
||||
_installMethod(
|
||||
subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value,
|
||||
(TParam5)args[4].Value);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
subContainer.ResolveRoots();
|
||||
};
|
||||
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// Six parameters
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByMethod<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> : SubContainerCreatorByMethodBase
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> _installMethod;
|
||||
|
||||
public SubContainerCreatorByMethod(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> installMethod)
|
||||
: base(container, containerBindInfo)
|
||||
{
|
||||
_installMethod = installMethod;
|
||||
}
|
||||
|
||||
public override DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 5);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
Assert.That(args[4].Type.DerivesFromOrEqual<TParam5>());
|
||||
Assert.That(args[5].Type.DerivesFromOrEqual<TParam6>());
|
||||
|
||||
var subContainer = CreateEmptySubContainer();
|
||||
|
||||
_installMethod(
|
||||
subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value,
|
||||
(TParam5)args[4].Value,
|
||||
(TParam6)args[5].Value);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
subContainer.ResolveRoots();
|
||||
};
|
||||
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// 10 parameters
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByMethod<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> : SubContainerCreatorByMethodBase
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> _installMethod;
|
||||
|
||||
public SubContainerCreatorByMethod(
|
||||
DiContainer container,
|
||||
SubContainerCreatorBindInfo containerBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> installMethod)
|
||||
: base(container, containerBindInfo)
|
||||
{
|
||||
_installMethod = installMethod;
|
||||
}
|
||||
|
||||
public override DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 10);
|
||||
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
Assert.That(args[4].Type.DerivesFromOrEqual<TParam5>());
|
||||
Assert.That(args[5].Type.DerivesFromOrEqual<TParam6>());
|
||||
Assert.That(args[6].Type.DerivesFromOrEqual<TParam7>());
|
||||
Assert.That(args[7].Type.DerivesFromOrEqual<TParam8>());
|
||||
Assert.That(args[8].Type.DerivesFromOrEqual<TParam9>());
|
||||
Assert.That(args[9].Type.DerivesFromOrEqual<TParam10>());
|
||||
|
||||
var subContainer = CreateEmptySubContainer();
|
||||
|
||||
_installMethod(
|
||||
subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value,
|
||||
(TParam5)args[4].Value,
|
||||
(TParam6)args[5].Value,
|
||||
(TParam7)args[6].Value,
|
||||
(TParam8)args[7].Value,
|
||||
(TParam9)args[8].Value,
|
||||
(TParam10)args[9].Value);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
subContainer.ResolveRoots();
|
||||
};
|
||||
|
||||
return subContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f4bb37c4e2a5bf44865ed1ab3bef21e
|
||||
timeCreated: 1461708050
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+366
@@ -0,0 +1,366 @@
|
||||
#if !NOT_UNITY3D
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using ModestTree;
|
||||
using Zenject.Internal;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public abstract class SubContainerCreatorByNewGameObjectDynamicContext : SubContainerCreatorDynamicContext
|
||||
{
|
||||
readonly GameObjectCreationParameters _gameObjectBindInfo;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectDynamicContext(
|
||||
DiContainer container, GameObjectCreationParameters gameObjectBindInfo)
|
||||
: base(container)
|
||||
{
|
||||
_gameObjectBindInfo = gameObjectBindInfo;
|
||||
}
|
||||
|
||||
protected override GameObject CreateGameObject(InjectContext context, out bool shouldMakeActive)
|
||||
{
|
||||
shouldMakeActive = true;
|
||||
var gameObject = Container.CreateEmptyGameObject(_gameObjectBindInfo, null);
|
||||
gameObject.SetActive(false);
|
||||
return gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewGameObjectInstaller : SubContainerCreatorByNewGameObjectDynamicContext
|
||||
{
|
||||
readonly Type _installerType;
|
||||
readonly List<TypeValuePair> _extraArgs;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectInstaller(
|
||||
DiContainer container,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Type installerType, List<TypeValuePair> extraArgs)
|
||||
: base(container, gameObjectBindInfo)
|
||||
{
|
||||
_installerType = installerType;
|
||||
_extraArgs = extraArgs;
|
||||
|
||||
Assert.That(installerType.DerivesFrom<InstallerBase>(),
|
||||
"Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType);
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
var extraArgs = ZenPools.SpawnList<TypeValuePair>();
|
||||
|
||||
extraArgs.AllocFreeAddRange(_extraArgs);
|
||||
extraArgs.AllocFreeAddRange(args);
|
||||
|
||||
var installer = (InstallerBase)subContainer.InstantiateExplicit(
|
||||
_installerType, extraArgs);
|
||||
|
||||
ZenPools.DespawnList(extraArgs);
|
||||
|
||||
installer.InstallBindings();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewGameObjectMethod : SubContainerCreatorByNewGameObjectDynamicContext
|
||||
{
|
||||
readonly Action<DiContainer> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectMethod(
|
||||
DiContainer container,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Action<DiContainer> installerMethod)
|
||||
: base(container, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.That(args.IsEmpty());
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(_installerMethod));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewGameObjectMethod<TParam1> : SubContainerCreatorByNewGameObjectDynamicContext
|
||||
{
|
||||
readonly Action<DiContainer, TParam1> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectMethod(
|
||||
DiContainer container,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Action<DiContainer, TParam1> installerMethod)
|
||||
: base(container, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 1);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer, (TParam1)args[0].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewGameObjectMethod<TParam1, TParam2> : SubContainerCreatorByNewGameObjectDynamicContext
|
||||
{
|
||||
readonly Action<DiContainer, TParam1, TParam2> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectMethod(
|
||||
DiContainer container,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Action<DiContainer, TParam1, TParam2> installerMethod)
|
||||
: base(container, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 2);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewGameObjectMethod<TParam1, TParam2, TParam3> : SubContainerCreatorByNewGameObjectDynamicContext
|
||||
{
|
||||
readonly Action<DiContainer, TParam1, TParam2, TParam3> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectMethod(
|
||||
DiContainer container,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Action<DiContainer, TParam1, TParam2, TParam3> installerMethod)
|
||||
: base(container, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 3);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewGameObjectMethod<TParam1, TParam2, TParam3, TParam4> : SubContainerCreatorByNewGameObjectDynamicContext
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectMethod(
|
||||
DiContainer container,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4> installerMethod)
|
||||
: base(container, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 4);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewGameObjectMethod<TParam1, TParam2, TParam3, TParam4, TParam5> : SubContainerCreatorByNewGameObjectDynamicContext
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectMethod(
|
||||
DiContainer container,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> installerMethod)
|
||||
: base(container, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 5);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
Assert.That(args[4].Type.DerivesFromOrEqual<TParam5>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value,
|
||||
(TParam5)args[4].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewGameObjectMethod<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> : SubContainerCreatorByNewGameObjectDynamicContext
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectMethod(
|
||||
DiContainer container,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> installerMethod)
|
||||
: base(container, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 5);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
Assert.That(args[4].Type.DerivesFromOrEqual<TParam5>());
|
||||
Assert.That(args[5].Type.DerivesFromOrEqual<TParam6>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value,
|
||||
(TParam5)args[4].Value,
|
||||
(TParam6)args[5].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewGameObjectMethod<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> : SubContainerCreatorByNewGameObjectDynamicContext
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewGameObjectMethod(
|
||||
DiContainer container,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> installerMethod)
|
||||
: base(container, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 10);
|
||||
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
Assert.That(args[4].Type.DerivesFromOrEqual<TParam5>());
|
||||
Assert.That(args[5].Type.DerivesFromOrEqual<TParam6>());
|
||||
Assert.That(args[6].Type.DerivesFromOrEqual<TParam7>());
|
||||
Assert.That(args[7].Type.DerivesFromOrEqual<TParam8>());
|
||||
Assert.That(args[8].Type.DerivesFromOrEqual<TParam9>());
|
||||
Assert.That(args[9].Type.DerivesFromOrEqual<TParam10>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value,
|
||||
(TParam5)args[4].Value,
|
||||
(TParam6)args[5].Value,
|
||||
(TParam7)args[6].Value,
|
||||
(TParam8)args[7].Value,
|
||||
(TParam9)args[8].Value,
|
||||
(TParam10)args[9].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c2c6880c82d78140818fe3204a0279b
|
||||
timeCreated: 1538467080
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#if !NOT_UNITY3D
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModestTree;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefab : ISubContainerCreator
|
||||
{
|
||||
readonly GameObjectCreationParameters _gameObjectBindInfo;
|
||||
readonly IPrefabProvider _prefabProvider;
|
||||
readonly DiContainer _container;
|
||||
|
||||
public SubContainerCreatorByNewPrefab(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo)
|
||||
{
|
||||
_gameObjectBindInfo = gameObjectBindInfo;
|
||||
_prefabProvider = prefabProvider;
|
||||
_container = container;
|
||||
}
|
||||
|
||||
public DiContainer CreateSubContainer(
|
||||
List<TypeValuePair> args, InjectContext parentContext, out Action injectAction)
|
||||
{
|
||||
Assert.That(args.IsEmpty());
|
||||
|
||||
var prefab = _prefabProvider.GetPrefab(parentContext);
|
||||
|
||||
bool shouldMakeActive;
|
||||
var gameObject = _container.CreateAndParentPrefab(
|
||||
prefab, _gameObjectBindInfo, null, out shouldMakeActive);
|
||||
|
||||
var context = gameObject.GetComponent<GameObjectContext>();
|
||||
|
||||
Assert.That(context != null,
|
||||
"Expected prefab with name '{0}' to contain a component of type 'GameObjectContext' on the root", prefab.name);
|
||||
|
||||
context.Install(_container);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
// Note: We don't need to call ResolveRoots here because GameObjectContext does this for us
|
||||
_container.Inject(context);
|
||||
|
||||
if (shouldMakeActive && !_container.IsValidating)
|
||||
{
|
||||
#if ZEN_INTERNAL_PROFILING
|
||||
using (ProfileTimers.CreateTimedBlock("User Code"))
|
||||
#endif
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return context.Container;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17fc7cad09fe4e94f939551c85abf6d9
|
||||
timeCreated: 1486859770
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+377
@@ -0,0 +1,377 @@
|
||||
#if !NOT_UNITY3D
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using ModestTree;
|
||||
using Zenject.Internal;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public abstract class SubContainerCreatorByNewPrefabDynamicContext : SubContainerCreatorDynamicContext
|
||||
{
|
||||
readonly IPrefabProvider _prefabProvider;
|
||||
readonly GameObjectCreationParameters _gameObjectBindInfo;
|
||||
|
||||
public SubContainerCreatorByNewPrefabDynamicContext(
|
||||
DiContainer container,
|
||||
IPrefabProvider prefabProvider, GameObjectCreationParameters gameObjectBindInfo)
|
||||
: base(container)
|
||||
{
|
||||
_prefabProvider = prefabProvider;
|
||||
_gameObjectBindInfo = gameObjectBindInfo;
|
||||
}
|
||||
|
||||
protected override GameObject CreateGameObject(InjectContext context, out bool shouldMakeActive)
|
||||
{
|
||||
var prefab = _prefabProvider.GetPrefab(context);
|
||||
|
||||
var gameObj = Container.CreateAndParentPrefab(
|
||||
prefab, _gameObjectBindInfo, null, out shouldMakeActive);
|
||||
|
||||
if (gameObj.GetComponent<GameObjectContext>() != null)
|
||||
{
|
||||
throw Assert.CreateException(
|
||||
"Found GameObjectContext already attached to prefab with name '{0}'! When using ByNewPrefabMethod or ByNewPrefabInstaller, the GameObjectContext is added to the prefab dynamically", prefab.name);
|
||||
}
|
||||
|
||||
return gameObj;
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabInstaller : SubContainerCreatorByNewPrefabDynamicContext
|
||||
{
|
||||
readonly Type _installerType;
|
||||
readonly List<TypeValuePair> _extraArgs;
|
||||
|
||||
public SubContainerCreatorByNewPrefabInstaller(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Type installerType, List<TypeValuePair> extraArgs)
|
||||
: base(container, prefabProvider, gameObjectBindInfo)
|
||||
{
|
||||
_installerType = installerType;
|
||||
_extraArgs = extraArgs;
|
||||
|
||||
Assert.That(installerType.DerivesFrom<InstallerBase>(),
|
||||
"Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType);
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
var extraArgs = ZenPools.SpawnList<TypeValuePair>();
|
||||
|
||||
extraArgs.AllocFreeAddRange(_extraArgs);
|
||||
extraArgs.AllocFreeAddRange(args);
|
||||
|
||||
var installer = (InstallerBase)subContainer.InstantiateExplicit(
|
||||
_installerType, extraArgs);
|
||||
|
||||
ZenPools.DespawnList(extraArgs);
|
||||
|
||||
installer.InstallBindings();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabMethod : SubContainerCreatorByNewPrefabDynamicContext
|
||||
{
|
||||
readonly Action<DiContainer> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewPrefabMethod(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Action<DiContainer> installerMethod)
|
||||
: base(container, prefabProvider, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.That(args.IsEmpty());
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(_installerMethod));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabMethod<TParam1> : SubContainerCreatorByNewPrefabDynamicContext
|
||||
{
|
||||
readonly Action<DiContainer, TParam1> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewPrefabMethod(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Action<DiContainer, TParam1> installerMethod)
|
||||
: base(container, prefabProvider, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 1);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer, (TParam1)args[0].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabMethod<TParam1, TParam2> : SubContainerCreatorByNewPrefabDynamicContext
|
||||
{
|
||||
readonly Action<DiContainer, TParam1, TParam2> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewPrefabMethod(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Action<DiContainer, TParam1, TParam2> installerMethod)
|
||||
: base(container, prefabProvider, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 2);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabMethod<TParam1, TParam2, TParam3> : SubContainerCreatorByNewPrefabDynamicContext
|
||||
{
|
||||
readonly Action<DiContainer, TParam1, TParam2, TParam3> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewPrefabMethod(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
Action<DiContainer, TParam1, TParam2, TParam3> installerMethod)
|
||||
: base(container, prefabProvider, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 3);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabMethod<TParam1, TParam2, TParam3, TParam4> : SubContainerCreatorByNewPrefabDynamicContext
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewPrefabMethod(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4> installerMethod)
|
||||
: base(container, prefabProvider, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 4);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabMethod<TParam1, TParam2, TParam3, TParam4, TParam5> : SubContainerCreatorByNewPrefabDynamicContext
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewPrefabMethod(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5> installerMethod)
|
||||
: base(container, prefabProvider, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 5);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
Assert.That(args[4].Type.DerivesFromOrEqual<TParam5>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value,
|
||||
(TParam5)args[4].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabMethod<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> : SubContainerCreatorByNewPrefabDynamicContext
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewPrefabMethod(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6> installerMethod)
|
||||
: base(container, prefabProvider, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 5);
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
Assert.That(args[4].Type.DerivesFromOrEqual<TParam5>());
|
||||
Assert.That(args[5].Type.DerivesFromOrEqual<TParam6>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value,
|
||||
(TParam5)args[4].Value,
|
||||
(TParam6)args[5].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabMethod<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> : SubContainerCreatorByNewPrefabDynamicContext
|
||||
{
|
||||
readonly
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> _installerMethod;
|
||||
|
||||
public SubContainerCreatorByNewPrefabMethod(
|
||||
DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo,
|
||||
#if !NET_4_6
|
||||
ModestTree.Util.
|
||||
#endif
|
||||
Action<DiContainer, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10> installerMethod)
|
||||
: base(container, prefabProvider, gameObjectBindInfo)
|
||||
{
|
||||
_installerMethod = installerMethod;
|
||||
}
|
||||
|
||||
protected override void AddInstallers(List<TypeValuePair> args, GameObjectContext context)
|
||||
{
|
||||
Assert.IsEqual(args.Count, 10);
|
||||
|
||||
Assert.That(args[0].Type.DerivesFromOrEqual<TParam1>());
|
||||
Assert.That(args[1].Type.DerivesFromOrEqual<TParam2>());
|
||||
Assert.That(args[2].Type.DerivesFromOrEqual<TParam3>());
|
||||
Assert.That(args[3].Type.DerivesFromOrEqual<TParam4>());
|
||||
Assert.That(args[4].Type.DerivesFromOrEqual<TParam5>());
|
||||
Assert.That(args[5].Type.DerivesFromOrEqual<TParam6>());
|
||||
Assert.That(args[6].Type.DerivesFromOrEqual<TParam7>());
|
||||
Assert.That(args[7].Type.DerivesFromOrEqual<TParam8>());
|
||||
Assert.That(args[8].Type.DerivesFromOrEqual<TParam9>());
|
||||
Assert.That(args[9].Type.DerivesFromOrEqual<TParam10>());
|
||||
|
||||
context.AddNormalInstaller(
|
||||
new ActionInstaller(subContainer =>
|
||||
{
|
||||
_installerMethod(subContainer,
|
||||
(TParam1)args[0].Value,
|
||||
(TParam2)args[1].Value,
|
||||
(TParam3)args[2].Value,
|
||||
(TParam4)args[3].Value,
|
||||
(TParam5)args[4].Value,
|
||||
(TParam6)args[5].Value,
|
||||
(TParam7)args[6].Value,
|
||||
(TParam8)args[7].Value,
|
||||
(TParam9)args[8].Value,
|
||||
(TParam10)args[9].Value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53f151c86cd3c4c46ada71b737004d36
|
||||
timeCreated: 1505722322
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
#if !NOT_UNITY3D
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ModestTree;
|
||||
using Zenject.Internal;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorByNewPrefabWithParams : ISubContainerCreator
|
||||
{
|
||||
readonly DiContainer _container;
|
||||
readonly IPrefabProvider _prefabProvider;
|
||||
readonly Type _installerType;
|
||||
readonly GameObjectCreationParameters _gameObjectBindInfo;
|
||||
|
||||
public SubContainerCreatorByNewPrefabWithParams(
|
||||
Type installerType, DiContainer container, IPrefabProvider prefabProvider,
|
||||
GameObjectCreationParameters gameObjectBindInfo)
|
||||
{
|
||||
_gameObjectBindInfo = gameObjectBindInfo;
|
||||
_prefabProvider = prefabProvider;
|
||||
_container = container;
|
||||
_installerType = installerType;
|
||||
}
|
||||
|
||||
protected DiContainer Container
|
||||
{
|
||||
get { return _container; }
|
||||
}
|
||||
|
||||
IEnumerable<InjectableInfo> GetAllInjectableIncludingBaseTypes()
|
||||
{
|
||||
var info = TypeAnalyzer.GetInfo(_installerType);
|
||||
|
||||
while (info != null)
|
||||
{
|
||||
foreach (var injectable in info.AllInjectables)
|
||||
{
|
||||
yield return injectable;
|
||||
}
|
||||
|
||||
info = info.BaseTypeInfo;
|
||||
}
|
||||
}
|
||||
|
||||
DiContainer CreateTempContainer(List<TypeValuePair> args)
|
||||
{
|
||||
var tempSubContainer = Container.CreateSubContainer();
|
||||
|
||||
var allInjectables = GetAllInjectableIncludingBaseTypes();
|
||||
|
||||
foreach (var argPair in args)
|
||||
{
|
||||
// We need to intelligently match on the exact parameters here to avoid the issue
|
||||
// brought up in github issue #217
|
||||
var match = allInjectables
|
||||
.Where(x => argPair.Type.DerivesFromOrEqual(x.MemberType))
|
||||
.OrderBy(x => ZenUtilInternal.GetInheritanceDelta(argPair.Type, x.MemberType)).FirstOrDefault();
|
||||
|
||||
Assert.That(match != null,
|
||||
"Could not find match for argument type '{0}' when injecting into sub container installer '{1}'",
|
||||
argPair.Type, _installerType);
|
||||
|
||||
tempSubContainer.Bind(match.MemberType)
|
||||
.FromInstance(argPair.Value).WhenInjectedInto(_installerType);
|
||||
}
|
||||
|
||||
return tempSubContainer;
|
||||
}
|
||||
|
||||
public DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext parentContext, out Action injectAction)
|
||||
{
|
||||
Assert.That(!args.IsEmpty());
|
||||
|
||||
var prefab = _prefabProvider.GetPrefab(parentContext);
|
||||
var tempContainer = CreateTempContainer(args);
|
||||
|
||||
bool shouldMakeActive;
|
||||
var gameObject = tempContainer.CreateAndParentPrefab(
|
||||
prefab, _gameObjectBindInfo, null, out shouldMakeActive);
|
||||
|
||||
var context = gameObject.GetComponent<GameObjectContext>();
|
||||
|
||||
Assert.That(context != null,
|
||||
"Expected prefab with name '{0}' to container a component of type 'GameObjectContext'", prefab.name);
|
||||
|
||||
context.Install(tempContainer);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
// Note: We don't need to call ResolveRoots here because GameObjectContext does this for us
|
||||
tempContainer.Inject(context);
|
||||
|
||||
if (shouldMakeActive && !_container.IsValidating)
|
||||
{
|
||||
#if ZEN_INTERNAL_PROFILING
|
||||
using (ProfileTimers.CreateTimedBlock("User Code"))
|
||||
#endif
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return context.Container;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07cb33e44f032a840a46b8b699927d0a
|
||||
timeCreated: 1486859770
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModestTree;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public class SubContainerCreatorCached : ISubContainerCreator
|
||||
{
|
||||
readonly ISubContainerCreator _subCreator;
|
||||
|
||||
#if ZEN_MULTITHREADING
|
||||
readonly object _locker = new object();
|
||||
#else
|
||||
bool _isLookingUp;
|
||||
#endif
|
||||
DiContainer _subContainer;
|
||||
|
||||
public SubContainerCreatorCached(ISubContainerCreator subCreator)
|
||||
{
|
||||
_subCreator = subCreator;
|
||||
}
|
||||
|
||||
public DiContainer CreateSubContainer(List<TypeValuePair> args, InjectContext context, out Action injectAction)
|
||||
{
|
||||
// We can't really support arguments if we are using the cached value since
|
||||
// the arguments might change when called after the first time
|
||||
Assert.IsEmpty(args);
|
||||
|
||||
#if ZEN_MULTITHREADING
|
||||
lock (_locker)
|
||||
#endif
|
||||
{
|
||||
if (_subContainer == null)
|
||||
{
|
||||
#if !ZEN_MULTITHREADING
|
||||
Assert.That(!_isLookingUp,
|
||||
"Found unresolvable circular dependency when looking up sub container! Object graph:\n {0}", context.GetObjectGraphString());
|
||||
_isLookingUp = true;
|
||||
#endif
|
||||
|
||||
_subContainer = _subCreator.CreateSubContainer(
|
||||
new List<TypeValuePair>(), context, out injectAction);
|
||||
|
||||
#if !ZEN_MULTITHREADING
|
||||
_isLookingUp = false;
|
||||
#endif
|
||||
|
||||
Assert.IsNotNull(_subContainer);
|
||||
}
|
||||
else
|
||||
{
|
||||
injectAction = null;
|
||||
}
|
||||
|
||||
return _subContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64db75da3b9de56409556af4513979c2
|
||||
timeCreated: 1461708051
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#if !NOT_UNITY3D
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using ModestTree;
|
||||
using Zenject.Internal;
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
[NoReflectionBaking]
|
||||
public abstract class SubContainerCreatorDynamicContext : ISubContainerCreator
|
||||
{
|
||||
readonly DiContainer _container;
|
||||
|
||||
public SubContainerCreatorDynamicContext(DiContainer container)
|
||||
{
|
||||
_container = container;
|
||||
}
|
||||
|
||||
protected DiContainer Container
|
||||
{
|
||||
get { return _container; }
|
||||
}
|
||||
|
||||
public DiContainer CreateSubContainer(
|
||||
List<TypeValuePair> args, InjectContext parentContext, out Action injectAction)
|
||||
{
|
||||
bool shouldMakeActive;
|
||||
var gameObj = CreateGameObject(parentContext, out shouldMakeActive);
|
||||
|
||||
var context = gameObj.AddComponent<GameObjectContext>();
|
||||
|
||||
AddInstallers(args, context);
|
||||
|
||||
context.Install(_container);
|
||||
|
||||
injectAction = () =>
|
||||
{
|
||||
// Note: We don't need to call ResolveRoots here because GameObjectContext does this for us
|
||||
_container.Inject(context);
|
||||
|
||||
if (shouldMakeActive && !_container.IsValidating)
|
||||
{
|
||||
#if ZEN_INTERNAL_PROFILING
|
||||
using (ProfileTimers.CreateTimedBlock("User Code"))
|
||||
#endif
|
||||
{
|
||||
gameObj.SetActive(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return context.Container;
|
||||
}
|
||||
|
||||
protected abstract void AddInstallers(List<TypeValuePair> args, GameObjectContext context);
|
||||
protected abstract GameObject CreateGameObject(InjectContext context, out bool shouldMakeActive);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba4736ebcee13cb4b9feca861072c740
|
||||
timeCreated: 1538467080
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using ModestTree;
|
||||
#if !NOT_UNITY3D
|
||||
using UnityEngine;
|
||||
#endif
|
||||
|
||||
namespace Zenject
|
||||
{
|
||||
public static class SubContainerCreatorUtil
|
||||
{
|
||||
public static void ApplyBindSettings(
|
||||
SubContainerCreatorBindInfo subContainerBindInfo, DiContainer subContainer)
|
||||
{
|
||||
if (subContainerBindInfo.CreateKernel)
|
||||
{
|
||||
var parentContainer = subContainer.ParentContainers.OnlyOrDefault();
|
||||
Assert.IsNotNull(parentContainer, "Could not find unique container when using WithKernel!");
|
||||
|
||||
if (subContainerBindInfo.KernelType != null)
|
||||
{
|
||||
parentContainer.Bind(typeof(Kernel).Interfaces()).To(subContainerBindInfo.KernelType)
|
||||
.FromSubContainerResolve()
|
||||
.ByInstance(subContainer).AsCached();
|
||||
subContainer.Bind(subContainerBindInfo.KernelType).AsCached();
|
||||
}
|
||||
else
|
||||
{
|
||||
parentContainer.BindInterfacesTo<Kernel>().FromSubContainerResolve()
|
||||
.ByInstance(subContainer).AsCached();
|
||||
subContainer.Bind<Kernel>().AsCached();
|
||||
}
|
||||
|
||||
#if !NOT_UNITY3D
|
||||
if (subContainerBindInfo.DefaultParentName != null)
|
||||
{
|
||||
DefaultGameObjectParentInstaller.Install(
|
||||
subContainer, subContainerBindInfo.DefaultParentName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c07a01bd5fbd00d43a50854896a92472
|
||||
timeCreated: 1534923026
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user