refactoring

This commit is contained in:
Mikhail 2023-06-04 19:42:46 +08:00
parent f4ef2fc284
commit 7d55cf82e4
2 changed files with 3 additions and 20 deletions

View File

@ -11,7 +11,6 @@ namespace DCFApixels.DragonECS
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class OptAttribute : InjectAttribute { }
public abstract class ImplicitInjectAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
public sealed class IncImplicitAttribute : ImplicitInjectAttribute
@ -21,16 +20,8 @@ namespace DCFApixels.DragonECS
public IncImplicitAttribute(Type type)
{
if (type.IsValueType && !type.IsPrimitive)
{
isPool = false;
this.type = type;
return;
}
if (!type.GetInterfaces().Any(o => o == typeof(IEcsPoolImplementation)))
throw new ArgumentException("Можно использовать только пулы наследованные от IEcsPoolImplementation<T>");
this.type = type;
isPool = true;
isPool = type.GetInterfaces().Any(o => o == typeof(IEcsPoolImplementation));
}
}
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
@ -40,16 +31,8 @@ namespace DCFApixels.DragonECS
public readonly bool isPool;
public ExcImplicitAttribute(Type type)
{
if (type.IsValueType && !type.IsPrimitive)
{
isPool = false;
this.type = type;
return;
}
if (!type.GetInterfaces().Any(o => o == typeof(IEcsPoolImplementation)))
throw new ArgumentException("Можно использовать только пулы наследованные от IEcsPoolImplementation<T>");
this.type = type;
isPool = true;
isPool = type.GetInterfaces().Any(o => o == typeof(IEcsPoolImplementation));
}
}
}

View File

@ -20,9 +20,9 @@ namespace DCFApixels.DragonECS
Type builderType = b.GetType();
MethodInfo incluedMethod = builderType.GetMethod("Include", BindingFlags.Instance | BindingFlags.Public);
MethodInfo excludeMethod = builderType.GetMethod("Exclude", BindingFlags.Instance | BindingFlags.Public);
MethodInfo optionalMethod = builderType.GetMethod("Optional", BindingFlags.Instance | BindingFlags.Public);
MethodInfo includeImplicitMethod = builderType.GetMethod("IncludeImplicit", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
MethodInfo excludeImplicitMethod = builderType.GetMethod("ExcludeImplicit", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
MethodInfo optionalMethod = builderType.GetMethod("Optional", BindingFlags.Instance | BindingFlags.Public);
Type subjectType = s.GetType();