mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
Update Injector.cs
This commit is contained in:
parent
9298ec7540
commit
95fc264c6f
@ -26,44 +26,23 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public void Inject<T>(T obj)
|
public void Inject<T>(T obj)
|
||||||
{
|
{
|
||||||
Type type = typeof(T);
|
Type type = obj.GetType();
|
||||||
#if DEBUG
|
|
||||||
if (obj.GetType() != type)
|
|
||||||
{
|
|
||||||
throw new ArgumentException();
|
|
||||||
}
|
|
||||||
if (IsCanInstantiated(type) == false)
|
|
||||||
{
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (_branches.TryGetValue(type, out InjectionBranch branch) == false)
|
if (_branches.TryGetValue(type, out InjectionBranch branch) == false)
|
||||||
{
|
{
|
||||||
InitNode(new InjectionNode<T>(type));
|
if (typeof(T) == type)
|
||||||
branch = new InjectionBranch(this, type, true);
|
{
|
||||||
InitBranch(branch);
|
InitNode(new InjectionNode<T>(type));
|
||||||
|
branch = new InjectionBranch(this, type, true);
|
||||||
|
InitBranch(branch);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
branch = new InjectionBranch(this, type, false);
|
||||||
|
InitBranch(branch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
branch.Inject(obj);
|
branch.Inject(obj);
|
||||||
}
|
}
|
||||||
// public void InjectNoBoxing<T>(T data) where T : struct
|
|
||||||
// {
|
|
||||||
// foreach (var system in _pipeline.GetProcess<IEcsInject<T>>())
|
|
||||||
// {
|
|
||||||
// system.Inject(data);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//#if !REFLECTION_DISABLED
|
|
||||||
// public void InjectRaw(object obj)
|
|
||||||
// {
|
|
||||||
// Type type = obj.GetType();
|
|
||||||
// if (_branches.TryGetValue(type, out InjectionBranch branch) == false)
|
|
||||||
// {
|
|
||||||
// branch = new InjectionBranch(this, type, false);
|
|
||||||
// InitBranch(branch);
|
|
||||||
// }
|
|
||||||
// branch.Inject(obj);
|
|
||||||
// }
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#region Internal
|
#region Internal
|
||||||
private void InitBranch(InjectionBranch branch)
|
private void InitBranch(InjectionBranch branch)
|
||||||
|
Loading…
Reference in New Issue
Block a user