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,13 +41,10 @@ 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)));
|
||||
@ -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)
|
||||
@ -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