refactor: Yaml serialization moved from Core to own project

This commit is contained in:
2025-05-01 17:51:21 +03:00
parent bd5eb432b7
commit 131203d578
35 changed files with 269 additions and 175 deletions

View File

@@ -5,12 +5,12 @@ using System.Reflection;
namespace Syntriax.Engine.Core.Serialization;
internal static class Utils
public static class Utils
{
internal static bool HasAttribute<T>(this MemberInfo memberInfo) where T : Attribute => memberInfo.GetCustomAttribute<T>() is not null;
internal static bool IsEnumerable(this Type type) => typeof(System.Collections.IEnumerable).IsAssignableFrom(type) && type != typeof(string);
public static bool HasAttribute<T>(this MemberInfo memberInfo) where T : Attribute => memberInfo.GetCustomAttribute<T>() is not null;
public static bool IsEnumerable(this Type type) => typeof(System.Collections.IEnumerable).IsAssignableFrom(type) && type != typeof(string);
internal static TypeData GetTypeData(this Type objectType)
public static TypeData GetTypeData(this Type objectType)
{
List<EventInfo> eventInfos = objectType.GetEvents(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
.OrderBy(ei => ei.Name)
@@ -26,7 +26,7 @@ internal static class Utils
return new TypeData(fieldInfos, propertyInfos);
}
internal static List<FieldInfo> GetFieldInfosIncludingBaseClasses(Type type, BindingFlags bindingFlags)
public static List<FieldInfo> GetFieldInfosIncludingBaseClasses(Type type, BindingFlags bindingFlags)
{
if (type.BaseType is null)
return [.. type.GetFields(bindingFlags)];
@@ -44,7 +44,7 @@ internal static class Utils
return [.. fieldInfoList.OrderBy(fi => fi.Name)];
}
internal static List<PropertyInfo> GetPropertyInfosIncludingBaseClasses(Type type, BindingFlags bindingFlags)
public static List<PropertyInfo> GetPropertyInfosIncludingBaseClasses(Type type, BindingFlags bindingFlags)
{
if (type.BaseType is null)
return [.. type.GetProperties(bindingFlags)];
@@ -75,7 +75,7 @@ internal static class Utils
}
}
internal record struct TypeData(IEnumerable<FieldInfo> Fields, IEnumerable<PropertyInfo> Properties)
public record struct TypeData(IEnumerable<FieldInfo> Fields, IEnumerable<PropertyInfo> Properties)
{
public static implicit operator (IEnumerable<FieldInfo> fields, IEnumerable<PropertyInfo> properties)(TypeData value) => (value.Fields, value.Properties);
public static implicit operator TypeData((IEnumerable<FieldInfo> fields, IEnumerable<PropertyInfo> properties) value) => new(value.fields, value.properties);