From 7d55cf82e4ac8f4415ade72eed93a84c7fd1d15c Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 4 Jun 2023 19:42:46 +0800 Subject: [PATCH] refactoring --- ...ueryAttributes.cs => SubjectAttributes.cs} | 21 ++----------------- src/Subject/EcsSubjectDI.cs | 2 +- 2 files changed, 3 insertions(+), 20 deletions(-) rename src/Attributes/{QueryAttributes.cs => SubjectAttributes.cs} (60%) diff --git a/src/Attributes/QueryAttributes.cs b/src/Attributes/SubjectAttributes.cs similarity index 60% rename from src/Attributes/QueryAttributes.cs rename to src/Attributes/SubjectAttributes.cs index e8122e8..7a5e35a 100644 --- a/src/Attributes/QueryAttributes.cs +++ b/src/Attributes/SubjectAttributes.cs @@ -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"); 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"); this.type = type; - isPool = true; + isPool = type.GetInterfaces().Any(o => o == typeof(IEcsPoolImplementation)); } } } diff --git a/src/Subject/EcsSubjectDI.cs b/src/Subject/EcsSubjectDI.cs index 253c3a4..8a02115 100644 --- a/src/Subject/EcsSubjectDI.cs +++ b/src/Subject/EcsSubjectDI.cs @@ -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();