rename IEcsDebugMetaProvider to IEcsMetaProvider

This commit is contained in:
Mikhail 2023-12-20 23:31:04 +08:00
parent e7c623daf8
commit 3cfdce4024
3 changed files with 33 additions and 33 deletions

View File

@ -63,16 +63,16 @@ namespace DCFApixels.DragonECS
#region GetName #region GetName
public static string GetName(object obj, int maxGenericDepth = 2) public static string GetName(object obj, int maxGenericDepth = 2)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
GetName(intr.DebugMetaSource, maxGenericDepth) : GetName(intr.MetaSource, maxGenericDepth) :
GetName(type: obj.GetType(), maxGenericDepth); GetName(type: obj.GetType(), maxGenericDepth);
} }
public static string GetName<T>(int maxGenericDepth = 2) => GetName(typeof(T), maxGenericDepth); public static string GetName<T>(int maxGenericDepth = 2) => GetName(typeof(T), maxGenericDepth);
public static string GetName(Type type, int maxGenericDepth = 2) => type.TryGetCustomAttribute(out MetaNameAttribute atr) ? atr.name : GetGenericTypeName(type, maxGenericDepth); public static string GetName(Type type, int maxGenericDepth = 2) => type.TryGetCustomAttribute(out MetaNameAttribute atr) ? atr.name : GetGenericTypeName(type, maxGenericDepth);
public static bool TryGetCustomName(object obj, out string name) public static bool TryGetCustomName(object obj, out string name)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
TryGetCustomName(intr.DebugMetaSource, out name) : TryGetCustomName(intr.MetaSource, out name) :
TryGetCustomName(type: obj.GetType(), out name); TryGetCustomName(type: obj.GetType(), out name);
} }
public static bool TryGetCustomName<T>(out string name) => TryGetCustomName(type: typeof(T), out name); public static bool TryGetCustomName<T>(out string name) => TryGetCustomName(type: typeof(T), out name);
@ -91,16 +91,16 @@ namespace DCFApixels.DragonECS
#region GetGroup #region GetGroup
public static MetaGroup GetGroup(object obj) public static MetaGroup GetGroup(object obj)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
GetGroup(intr.DebugMetaSource) : GetGroup(intr.MetaSource) :
GetGroup(type: obj.GetType()); GetGroup(type: obj.GetType());
} }
public static MetaGroup GetGroup<T>() => GetGroup(typeof(T)); public static MetaGroup GetGroup<T>() => GetGroup(typeof(T));
public static MetaGroup GetGroup(Type type) => type.TryGetCustomAttribute(out MetaGroupAttribute atr) ? atr.GetData() : MetaGroup.Empty; public static MetaGroup GetGroup(Type type) => type.TryGetCustomAttribute(out MetaGroupAttribute atr) ? atr.GetData() : MetaGroup.Empty;
public static bool TryGetGroup(object obj, out MetaGroup group) public static bool TryGetGroup(object obj, out MetaGroup group)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
TryGetGroup(intr.DebugMetaSource, out group) : TryGetGroup(intr.MetaSource, out group) :
TryGetGroup(type: obj.GetType(), out group); TryGetGroup(type: obj.GetType(), out group);
} }
public static bool TryGetGroup<T>(out MetaGroup text) => TryGetGroup(typeof(T), out text); public static bool TryGetGroup<T>(out MetaGroup text) => TryGetGroup(typeof(T), out text);
@ -119,16 +119,16 @@ namespace DCFApixels.DragonECS
#region GetDescription #region GetDescription
public static string GetDescription(object obj) public static string GetDescription(object obj)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
GetDescription(intr.DebugMetaSource) : GetDescription(intr.MetaSource) :
GetDescription(type: obj.GetType()); GetDescription(type: obj.GetType());
} }
public static string GetDescription<T>() => GetDescription(typeof(T)); public static string GetDescription<T>() => GetDescription(typeof(T));
public static string GetDescription(Type type) => type.TryGetCustomAttribute(out MetaDescriptionAttribute atr) ? atr.description : string.Empty; public static string GetDescription(Type type) => type.TryGetCustomAttribute(out MetaDescriptionAttribute atr) ? atr.description : string.Empty;
public static bool TryGetDescription(object obj, out string text) public static bool TryGetDescription(object obj, out string text)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
TryGetDescription(intr.DebugMetaSource, out text) : TryGetDescription(intr.MetaSource, out text) :
TryGetDescription(type: obj.GetType(), out text); TryGetDescription(type: obj.GetType(), out text);
} }
public static bool TryGetDescription<T>(out string text) => TryGetDescription(typeof(T), out text); public static bool TryGetDescription<T>(out string text) => TryGetDescription(typeof(T), out text);
@ -227,8 +227,8 @@ namespace DCFApixels.DragonECS
public static MetaColor GetColor(object obj) public static MetaColor GetColor(object obj)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
GetColor(intr.DebugMetaSource) : GetColor(intr.MetaSource) :
GetColor(type: obj.GetType()); GetColor(type: obj.GetType());
} }
public static MetaColor GetColor<T>() => GetColor(typeof(T)); public static MetaColor GetColor<T>() => GetColor(typeof(T));
@ -244,8 +244,8 @@ namespace DCFApixels.DragonECS
} }
public static bool TryGetColor(object obj, out MetaColor color) public static bool TryGetColor(object obj, out MetaColor color)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
TryGetColor(intr.DebugMetaSource, out color) : TryGetColor(intr.MetaSource, out color) :
TryGetColor(type: obj.GetType(), out color); TryGetColor(type: obj.GetType(), out color);
} }
public static bool TryGetColor<T>(out MetaColor color) => TryGetColor(typeof(T), out color); public static bool TryGetColor<T>(out MetaColor color) => TryGetColor(typeof(T), out color);
@ -265,8 +265,8 @@ namespace DCFApixels.DragonECS
#region GetTags #region GetTags
public static IReadOnlyCollection<string> GetTags(object obj) public static IReadOnlyCollection<string> GetTags(object obj)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
GetTags(intr.DebugMetaSource) : GetTags(intr.MetaSource) :
GetTags(type: obj.GetType()); GetTags(type: obj.GetType());
} }
public static IReadOnlyCollection<string> GetTags<T>() => GetTags(typeof(T)); public static IReadOnlyCollection<string> GetTags<T>() => GetTags(typeof(T));
@ -278,8 +278,8 @@ namespace DCFApixels.DragonECS
public static bool TryGetTags(object obj, out IReadOnlyCollection<string> tags) public static bool TryGetTags(object obj, out IReadOnlyCollection<string> tags)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
TryGetTags(intr.DebugMetaSource, out tags) : TryGetTags(intr.MetaSource, out tags) :
TryGetTags(type: obj.GetType(), out tags); TryGetTags(type: obj.GetType(), out tags);
} }
public static bool TryGetTags<T>(out IReadOnlyCollection<string> tags) => TryGetTags(typeof(T), out tags); public static bool TryGetTags<T>(out IReadOnlyCollection<string> tags) => TryGetTags(typeof(T), out tags);
@ -299,8 +299,8 @@ namespace DCFApixels.DragonECS
#region IsHidden #region IsHidden
public static bool IsHidden(object obj) public static bool IsHidden(object obj)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
IsHidden(intr.DebugMetaSource) : IsHidden(intr.MetaSource) :
IsHidden(type: obj.GetType()); IsHidden(type: obj.GetType());
} }
public static bool IsHidden<T>() => IsHidden(typeof(T)); public static bool IsHidden<T>() => IsHidden(typeof(T));
@ -310,19 +310,19 @@ namespace DCFApixels.DragonECS
#region MetaSource #region MetaSource
public static bool IsMetaSourceProvided(object obj) public static bool IsMetaSourceProvided(object obj)
{ {
return obj is IEcsDebugMetaProvider; return obj is IEcsMetaProvider;
} }
public static object GetMetaSource(object obj) public static object GetMetaSource(object obj)
{ {
return obj is IEcsDebugMetaProvider intr ? intr.DebugMetaSource : obj; return obj is IEcsMetaProvider intr ? intr.MetaSource : obj;
} }
#endregion #endregion
#region GenerateTypeDebugData #region GenerateTypeDebugData
public static TypeMetaData GenerateTypeDebugData(object obj) public static TypeMetaData GenerateTypeDebugData(object obj)
{ {
return obj is IEcsDebugMetaProvider intr ? return obj is IEcsMetaProvider intr ?
GenerateTypeDebugData(intr.DebugMetaSource) : GenerateTypeDebugData(intr.MetaSource) :
GenerateTypeDebugData(type: obj.GetType()); GenerateTypeDebugData(type: obj.GetType());
} }
public static TypeMetaData GenerateTypeDebugData<T>() => GenerateTypeDebugData(typeof(T)); public static TypeMetaData GenerateTypeDebugData<T>() => GenerateTypeDebugData(typeof(T));

View File

@ -1,7 +0,0 @@
namespace DCFApixels.DragonECS
{
public interface IEcsDebugMetaProvider
{
object DebugMetaSource { get; }
}
}

View File

@ -0,0 +1,7 @@
namespace DCFApixels.DragonECS
{
public interface IEcsMetaProvider
{
object MetaSource { get; }
}
}