refactor: renamed converters to serializers
This commit is contained in:
parent
d70bee2c6b
commit
6e7a0993f5
@ -17,7 +17,7 @@ public static class Serializer
|
||||
.WithNamingConvention(PascalCaseNamingConvention.Instance)
|
||||
.DisableAliases();
|
||||
|
||||
foreach (IEngineTypeYamlConverter typeConverter in GetEngineYamlTypeConverters())
|
||||
foreach (IEngineTypeYamlSerializer typeConverter in GetEngineYamlTypeConverters())
|
||||
serializerBuilder = serializerBuilder.WithTypeConverter(typeConverter);
|
||||
|
||||
return serializerBuilder.Build();
|
||||
@ -29,16 +29,16 @@ public static class Serializer
|
||||
DeserializerBuilder serializerBuilder = new DeserializerBuilder()
|
||||
.WithNamingConvention(PascalCaseNamingConvention.Instance);
|
||||
|
||||
foreach (IEngineTypeYamlConverter typeConverter in GetEngineYamlTypeConverters())
|
||||
foreach (IEngineTypeYamlSerializer typeConverter in GetEngineYamlTypeConverters())
|
||||
serializerBuilder = serializerBuilder.WithTypeConverter(typeConverter);
|
||||
|
||||
return serializerBuilder.Build();
|
||||
}
|
||||
|
||||
private static IEnumerable<IEngineTypeYamlConverter> GetEngineYamlTypeConverters()
|
||||
private static IEnumerable<IEngineTypeYamlSerializer> GetEngineYamlTypeConverters()
|
||||
{
|
||||
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes().Where(t => typeof(IEngineTypeYamlConverter).IsAssignableFrom(t) && t.IsClass && !t.IsAbstract))
|
||||
yield return (Activator.CreateInstance(type) as IEngineTypeYamlConverter)!;
|
||||
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes().Where(t => typeof(IEngineTypeYamlSerializer).IsAssignableFrom(t) && t.IsClass && !t.IsAbstract))
|
||||
yield return (Activator.CreateInstance(type) as IEngineTypeYamlSerializer)!;
|
||||
}
|
||||
|
||||
public static string Serialize(object instance)
|
||||
|
@ -2,4 +2,4 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public interface IEngineTypeYamlConverter : IYamlTypeConverter;
|
||||
public interface IEngineTypeYamlSerializer : IYamlTypeConverter;
|
@ -8,7 +8,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class BehaviourControllerConverter : IEngineTypeYamlConverter
|
||||
public class BehaviourControllerSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
private const string SERIALIZED_SCALAR_NAME = "Properties";
|
||||
private const string BEHAVIOURS_SCALAR_NAME = "Behaviours";
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class BehaviourConverter : IEngineTypeYamlConverter
|
||||
public class BehaviourSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
private const string SERIALIZED_SCALAR_NAME = "Properties";
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class AABBConverter : IEngineTypeYamlConverter
|
||||
public class AABBSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
public bool Accepts(Type type) => type == typeof(AABB);
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class CircleConverter : IEngineTypeYamlConverter
|
||||
public class CircleSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
public bool Accepts(Type type) => type == typeof(Circle);
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class Line2DEquationConverter : IEngineTypeYamlConverter
|
||||
public class Line2DEquationSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
public bool Accepts(Type type) => type == typeof(Line2DEquation);
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class Line2DConverter : IEngineTypeYamlConverter
|
||||
public class Line2DSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
public bool Accepts(Type type) => type == typeof(Line2D);
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class Projection1DConverter : IEngineTypeYamlConverter
|
||||
public class Projection1DSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
public bool Accepts(Type type) => type == typeof(Projection1D);
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class QuaternionConverter : IEngineTypeYamlConverter
|
||||
public class QuaternionSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
private static readonly int SUBSTRING_START_LENGTH = nameof(Quaternion).Length + 1;
|
||||
|
@ -7,7 +7,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class Shape2DConverter : IEngineTypeYamlConverter
|
||||
public class Shape2DSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
public bool Accepts(Type type) => type == typeof(Shape2D);
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class TriangleConverter : IEngineTypeYamlConverter
|
||||
public class TriangleSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
public bool Accepts(Type type) => type == typeof(Triangle);
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class Vector2DConverter : IEngineTypeYamlConverter
|
||||
public class Vector2DSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
private static readonly int SUBSTRING_START_LENGTH = nameof(Vector2D).Length + 1;
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class Vector3DConverter : IEngineTypeYamlConverter
|
||||
public class Vector3DSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
private static readonly int SUBSTRING_START_LENGTH = nameof(Vector3D).Length + 1;
|
||||
|
@ -10,7 +10,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class SerializedClassConverter : IEngineTypeYamlConverter
|
||||
public class SerializedClassSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
public bool Accepts(Type type) => type == typeof(SerializedClass);
|
||||
|
@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class StateEnableConverter : IEngineTypeYamlConverter
|
||||
public class StateEnableSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
private const string SERIALIZED_SCALAR_NAME = "Properties";
|
||||
|
@ -8,7 +8,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class TypeContainerConverter : IEngineTypeYamlConverter
|
||||
public class TypeContainerSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
public bool Accepts(Type type) => type == typeof(TypeContainer);
|
||||
|
@ -8,7 +8,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Syntriax.Engine.Core.Serialization;
|
||||
|
||||
public class UniverseObjectConverter : IEngineTypeYamlConverter
|
||||
public class UniverseObjectSerializer : IEngineTypeYamlSerializer
|
||||
{
|
||||
private const string SERIALIZED_SCALAR_NAME = "Properties";
|
||||
|
Loading…
x
Reference in New Issue
Block a user