add inject null check

This commit is contained in:
Mikhail 2023-06-13 15:55:44 +08:00
parent 840ccb2782
commit 7b5c912ebd

View File

@ -2,6 +2,7 @@
using DCFApixels.DragonECS.RunnersCore;
using System;
using System.Linq;
using System.Runtime.CompilerServices;
namespace DCFApixels.DragonECS
{
@ -58,9 +59,12 @@ namespace DCFApixels.DragonECS
private EcsBaseTypeInjectRunner _baseTypeInjectRunner;
void IEcsInject<T>.Inject(T obj)
{
if (obj == null) ThrowArgumentNullException();
_baseTypeInjectRunner.Inject(obj);
foreach (var item in targets) item.Inject(obj);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ThrowArgumentNullException() => throw new ArgumentNullException();
protected override void OnSetup()
{
Type baseType = typeof(T).BaseType;