Make Strings namespace and move Xbox

This commit is contained in:
Matt Nadareski
2023-10-24 23:20:27 -04:00
parent 1f70e1f544
commit 83450f693f
8 changed files with 67 additions and 37 deletions

View File

@@ -1,15 +0,0 @@
using System;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class XMID : IFileSerializer<Models.Xbox.XMID>
{
/// <inheritdoc/>
#if NET48
public bool Serialize(Models.Xbox.XMID obj, string path) => throw new NotImplementedException();
#else
public bool Serialize(Models.Xbox.XMID? obj, string? path) => throw new NotImplementedException();
#endif
}
}

View File

@@ -1,15 +0,0 @@
using System;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class XeMID : IFileSerializer<Models.Xbox.XeMID>
{
/// <inheritdoc/>
#if NET48
public bool Serialize(Models.Xbox.XeMID obj, string path) => throw new NotImplementedException();
#else
public bool Serialize(Models.Xbox.XeMID? obj, string? path) => throw new NotImplementedException();
#endif
}
}

View File

@@ -18,7 +18,7 @@ namespace SabreTools.Serialization.Interfaces
#endif
/// <summary>
/// Sserialize a <typeparamref name="T"/> into a file
/// Serialize a <typeparamref name="T"/> into a file
/// </summary>
/// <typeparam name="T">Type of object to serialize from</typeparam>
/// <param name="obj">Data to serialize</param>

View File

@@ -0,0 +1,32 @@
namespace SabreTools.Serialization.Interfaces
{
/// <summary>
/// Defines how to serialize to and from strings
/// </summary>
public interface IStringSerializer<T>
{
/// <summary>
/// Deserialize a string into <typeparamref name="T"/>
/// </summary>
/// <typeparam name="T">Type of object to deserialize to</typeparam>
/// <param name="str">String to deserialize from</param>
/// <returns>Filled object on success, null on error</returns>
#if NET48
T Deserialize(string str);
#else
T? Deserialize(string? str);
#endif
/// <summary>
/// Serialize a <typeparamref name="T"/> into a string
/// </summary>
/// <typeparam name="T">Type of object to serialize from</typeparam>
/// <param name="obj">Data to serialize</param>
/// <returns>Filled string on successful serialization, null otherwise</returns>
#if NET48
string Serialize(T obj);
#else
string? Serialize(T? obj);
#endif
}
}

View File

@@ -1,11 +1,10 @@
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
namespace SabreTools.Serialization.Strings
{
public partial class XMID : IFileSerializer<Models.Xbox.XMID>
public partial class XMID : IStringSerializer<Models.Xbox.XMID>
{
/// <inheritdoc/>
/// <remarks>This treats the input path like a parseable string</remarks>
#if NET48
public Models.Xbox.XMID Deserialize(string path)
#else

View File

@@ -0,0 +1,15 @@
using System;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Strings
{
public partial class XMID : IStringSerializer<Models.Xbox.XMID>
{
/// <inheritdoc/>
#if NET48
public string Serialize(Models.Xbox.XMID obj) => throw new NotImplementedException();
#else
public string? Serialize(Models.Xbox.XMID? obj) => throw new NotImplementedException();
#endif
}
}

View File

@@ -1,11 +1,10 @@
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
namespace SabreTools.Serialization.Strings
{
public partial class XeMID : IFileSerializer<Models.Xbox.XeMID>
public partial class XeMID : IStringSerializer<Models.Xbox.XeMID>
{
/// <inheritdoc/>
/// <remarks>This treats the input path like a parseable string</remarks>
#if NET48
public Models.Xbox.XeMID Deserialize(string path)
#else

View File

@@ -0,0 +1,15 @@
using System;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Strings
{
public partial class XeMID : IStringSerializer<Models.Xbox.XeMID>
{
/// <inheritdoc/>
#if NET48
public string Serialize(Models.Xbox.XeMID obj) => throw new NotImplementedException();
#else
public string? Serialize(Models.Xbox.XeMID? obj) => throw new NotImplementedException();
#endif
}
}