mirror of
https://github.com/DCFApixels/DragonECS-AutoInjections.git
synced 2025-09-17 20:34:34 +08:00
refactoring to support c# 7.3
This commit is contained in:
parent
9459d6d003
commit
48d745ff9a
@ -41,18 +41,15 @@ namespace DCFApixels.DragonECS
|
||||
foreach (var item in _systemProoperties.Keys)
|
||||
_notInjected.Add(item);
|
||||
}
|
||||
private static List<IInjectedProperty> GetAllPropertiesFor(Type type)
|
||||
|
||||
private static void Do(Type type, List<IInjectedProperty> result)
|
||||
{
|
||||
const BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
List<IInjectedProperty> result = new List<IInjectedProperty>();
|
||||
Do(type, result);
|
||||
static void Do(Type type, List<IInjectedProperty> result)
|
||||
{
|
||||
result.AddRange(type.GetFields(bindingFlags)
|
||||
.Where(o => o.GetCustomAttribute<EcsInjectAttribute>() != null)
|
||||
.Select(o => new InjectedField(o)));
|
||||
result.AddRange(type.GetProperties(bindingFlags)
|
||||
.Where(o =>{
|
||||
.Where(o => {
|
||||
if (o.GetCustomAttribute<EcsInjectAttribute>() == null)
|
||||
return false;
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
@ -78,6 +75,11 @@ namespace DCFApixels.DragonECS
|
||||
if (type.BaseType != null)
|
||||
Do(type.BaseType, result);
|
||||
}
|
||||
|
||||
private static List<IInjectedProperty> GetAllPropertiesFor(Type type)
|
||||
{
|
||||
List<IInjectedProperty> result = new List<IInjectedProperty>();
|
||||
Do(type, result);
|
||||
return result;
|
||||
}
|
||||
public void Inject(Type fieldType, object obj)
|
||||
@ -119,7 +121,7 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
WarningMissedInjections();
|
||||
_notInjected.Clear();
|
||||
_notInjected= null;
|
||||
_notInjected = null;
|
||||
}
|
||||
|
||||
private void WarningMissedInjections()
|
||||
@ -155,7 +157,7 @@ namespace DCFApixels.DragonECS
|
||||
private bool _isPreInjectionComplete = false;
|
||||
public void PreInject(object obj)
|
||||
{
|
||||
if(_pipeline == null)
|
||||
if (_pipeline == null)
|
||||
{
|
||||
_injectQueue.Add(obj);
|
||||
return;
|
||||
@ -205,8 +207,8 @@ namespace DCFApixels.DragonECS
|
||||
#region Utils
|
||||
internal interface IInjectedProperty
|
||||
{
|
||||
public bool IsInjected { get; }
|
||||
public Type PropertyType { get; }
|
||||
bool IsInjected { get; }
|
||||
Type PropertyType { get; }
|
||||
EcsInjectAttribute GetAutoInjectAttribute();
|
||||
void Inject(object target, object value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user