refactoring to support c# 7.3

This commit is contained in:
Mikhail 2023-06-12 22:12:30 +08:00
parent 9459d6d003
commit 48d745ff9a

View File

@ -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);
}