mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-02-05 17:02:49 +02:00
Add XML docs for public serialization
This commit is contained in:
parent
0d19127fb7
commit
7fbf0160d6
9 changed files with 103 additions and 0 deletions
|
@ -3,7 +3,14 @@ using DotTiled.Model;
|
||||||
|
|
||||||
namespace DotTiled.Serialization;
|
namespace DotTiled.Serialization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for reading a map from some source. Used by the different file format parsers to read a map.
|
||||||
|
/// </summary>
|
||||||
public interface IMapReader : IDisposable
|
public interface IMapReader : IDisposable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a map from the source.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The parsed map.</returns>
|
||||||
Map ReadMap();
|
Map ReadMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,14 @@ using DotTiled.Model;
|
||||||
|
|
||||||
namespace DotTiled.Serialization;
|
namespace DotTiled.Serialization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for reading a template from some source. Used by the different file format parsers to read a template.
|
||||||
|
/// </summary>
|
||||||
public interface ITemplateReader : IDisposable
|
public interface ITemplateReader : IDisposable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a template from the source.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The parsed template.</returns>
|
||||||
Template ReadTemplate();
|
Template ReadTemplate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,14 @@ using DotTiled.Model;
|
||||||
|
|
||||||
namespace DotTiled.Serialization;
|
namespace DotTiled.Serialization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for reading a tileset from some source. Used by the different file format parsers to read a tileset.
|
||||||
|
/// </summary>
|
||||||
public interface ITilesetReader : IDisposable
|
public interface ITilesetReader : IDisposable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a tileset from the source.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The parsed tileset.</returns>
|
||||||
Tileset ReadTileset();
|
Tileset ReadTileset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ using DotTiled.Model;
|
||||||
|
|
||||||
namespace DotTiled.Serialization.Tmj;
|
namespace DotTiled.Serialization.Tmj;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A template reader for reading Tiled JSON templates.
|
||||||
|
/// </summary>
|
||||||
public class TjTemplateReader : ITemplateReader
|
public class TjTemplateReader : ITemplateReader
|
||||||
{
|
{
|
||||||
// External resolvers
|
// External resolvers
|
||||||
|
@ -15,6 +18,14 @@ public class TjTemplateReader : ITemplateReader
|
||||||
|
|
||||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new <see cref="TjTemplateReader"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jsonString">A string containing a Tiled template in the Tiled JSON format.</param>
|
||||||
|
/// <param name="externalTilesetResolver">A function that resolves external tilesets given their source.</param>
|
||||||
|
/// <param name="externalTemplateResolver">A function that resolves external templates given their source.</param>
|
||||||
|
/// <param name="customTypeDefinitions">A collection of custom type definitions that can be used to resolve custom types when encountering <see cref="ClassProperty"/>.</param>
|
||||||
|
/// <exception cref="ArgumentNullException">Thrown when any of the arguments are null.</exception>
|
||||||
public TjTemplateReader(
|
public TjTemplateReader(
|
||||||
string jsonString,
|
string jsonString,
|
||||||
Func<string, Tileset> externalTilesetResolver,
|
Func<string, Tileset> externalTilesetResolver,
|
||||||
|
@ -27,6 +38,7 @@ public class TjTemplateReader : ITemplateReader
|
||||||
_customTypeDefinitions = customTypeDefinitions ?? throw new ArgumentNullException(nameof(customTypeDefinitions));
|
_customTypeDefinitions = customTypeDefinitions ?? throw new ArgumentNullException(nameof(customTypeDefinitions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public Template ReadTemplate()
|
public Template ReadTemplate()
|
||||||
{
|
{
|
||||||
var jsonDoc = System.Text.Json.JsonDocument.Parse(_jsonString);
|
var jsonDoc = System.Text.Json.JsonDocument.Parse(_jsonString);
|
||||||
|
@ -34,6 +46,7 @@ public class TjTemplateReader : ITemplateReader
|
||||||
return Tmj.ReadTemplate(rootElement, _externalTilesetResolver, _externalTemplateResolver, _customTypeDefinitions);
|
return Tmj.ReadTemplate(rootElement, _externalTilesetResolver, _externalTemplateResolver, _customTypeDefinitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!disposedValue)
|
if (!disposedValue)
|
||||||
|
@ -56,6 +69,7 @@ public class TjTemplateReader : ITemplateReader
|
||||||
// Dispose(disposing: false);
|
// Dispose(disposing: false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||||
|
|
|
@ -7,6 +7,9 @@ using DotTiled.Model;
|
||||||
|
|
||||||
namespace DotTiled.Serialization.Tmj;
|
namespace DotTiled.Serialization.Tmj;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A map reader for reading Tiled JSON maps.
|
||||||
|
/// </summary>
|
||||||
public class TmjMapReader : IMapReader
|
public class TmjMapReader : IMapReader
|
||||||
{
|
{
|
||||||
// External resolvers
|
// External resolvers
|
||||||
|
@ -18,6 +21,14 @@ public class TmjMapReader : IMapReader
|
||||||
|
|
||||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new <see cref="TmjMapReader"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jsonString">A string containing a Tiled map in the Tiled JSON format.</param>
|
||||||
|
/// <param name="externalTilesetResolver">A function that resolves external tilesets given their source.</param>
|
||||||
|
/// <param name="externalTemplateResolver">A function that resolves external templates given their source.</param>
|
||||||
|
/// <param name="customTypeDefinitions">A collection of custom type definitions that can be used to resolve custom types when encountering <see cref="ClassProperty"/>.</param>
|
||||||
|
/// <exception cref="ArgumentNullException">Thrown when any of the arguments are null.</exception>
|
||||||
public TmjMapReader(
|
public TmjMapReader(
|
||||||
string jsonString,
|
string jsonString,
|
||||||
Func<string, Tileset> externalTilesetResolver,
|
Func<string, Tileset> externalTilesetResolver,
|
||||||
|
@ -30,6 +41,7 @@ public class TmjMapReader : IMapReader
|
||||||
_customTypeDefinitions = customTypeDefinitions ?? throw new ArgumentNullException(nameof(customTypeDefinitions));
|
_customTypeDefinitions = customTypeDefinitions ?? throw new ArgumentNullException(nameof(customTypeDefinitions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public Map ReadMap()
|
public Map ReadMap()
|
||||||
{
|
{
|
||||||
var jsonDoc = JsonDocument.Parse(_jsonString);
|
var jsonDoc = JsonDocument.Parse(_jsonString);
|
||||||
|
@ -37,6 +49,7 @@ public class TmjMapReader : IMapReader
|
||||||
return Tmj.ReadMap(rootElement, _externalTilesetResolver, _externalTemplateResolver, _customTypeDefinitions);
|
return Tmj.ReadMap(rootElement, _externalTilesetResolver, _externalTemplateResolver, _customTypeDefinitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!disposedValue)
|
if (!disposedValue)
|
||||||
|
@ -59,6 +72,7 @@ public class TmjMapReader : IMapReader
|
||||||
// Dispose(disposing: false);
|
// Dispose(disposing: false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||||
|
|
|
@ -4,6 +4,9 @@ using DotTiled.Model;
|
||||||
|
|
||||||
namespace DotTiled.Serialization.Tmj;
|
namespace DotTiled.Serialization.Tmj;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A tileset reader for the Tiled JSON format.
|
||||||
|
/// </summary>
|
||||||
public class TsjTilesetReader : ITilesetReader
|
public class TsjTilesetReader : ITilesetReader
|
||||||
{
|
{
|
||||||
// External resolvers
|
// External resolvers
|
||||||
|
@ -14,6 +17,13 @@ public class TsjTilesetReader : ITilesetReader
|
||||||
|
|
||||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new <see cref="TsjTilesetReader"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jsonString">A string containing a Tiled tileset in the Tiled JSON format.</param>
|
||||||
|
/// <param name="externalTemplateResolver">A function that resolves external templates given their source.</param>
|
||||||
|
/// <param name="customTypeDefinitions">A collection of custom type definitions that can be used to resolve custom types when encountering <see cref="ClassProperty"/>.</param>
|
||||||
|
/// <exception cref="ArgumentNullException">Thrown when any of the arguments are null.</exception>
|
||||||
public TsjTilesetReader(
|
public TsjTilesetReader(
|
||||||
string jsonString,
|
string jsonString,
|
||||||
Func<string, Template> externalTemplateResolver,
|
Func<string, Template> externalTemplateResolver,
|
||||||
|
@ -24,6 +34,7 @@ public class TsjTilesetReader : ITilesetReader
|
||||||
_customTypeDefinitions = customTypeDefinitions ?? throw new ArgumentNullException(nameof(customTypeDefinitions));
|
_customTypeDefinitions = customTypeDefinitions ?? throw new ArgumentNullException(nameof(customTypeDefinitions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public Tileset ReadTileset()
|
public Tileset ReadTileset()
|
||||||
{
|
{
|
||||||
var jsonDoc = System.Text.Json.JsonDocument.Parse(_jsonString);
|
var jsonDoc = System.Text.Json.JsonDocument.Parse(_jsonString);
|
||||||
|
@ -35,6 +46,7 @@ public class TsjTilesetReader : ITilesetReader
|
||||||
_customTypeDefinitions);
|
_customTypeDefinitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!disposedValue)
|
if (!disposedValue)
|
||||||
|
@ -57,6 +69,7 @@ public class TsjTilesetReader : ITilesetReader
|
||||||
// Dispose(disposing: false);
|
// Dispose(disposing: false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||||
|
|
|
@ -5,6 +5,9 @@ using DotTiled.Model;
|
||||||
|
|
||||||
namespace DotTiled.Serialization.Tmx;
|
namespace DotTiled.Serialization.Tmx;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A map reader for the Tiled XML format.
|
||||||
|
/// </summary>
|
||||||
public class TmxMapReader : IMapReader
|
public class TmxMapReader : IMapReader
|
||||||
{
|
{
|
||||||
// External resolvers
|
// External resolvers
|
||||||
|
@ -16,6 +19,14 @@ public class TmxMapReader : IMapReader
|
||||||
|
|
||||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new <see cref="TmxMapReader"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An XML reader for reading a Tiled map in the Tiled XML format.</param>
|
||||||
|
/// <param name="externalTilesetResolver">A function that resolves external tilesets given their source.</param>
|
||||||
|
/// <param name="externalTemplateResolver">A function that resolves external templates given their source.</param>
|
||||||
|
/// <param name="customTypeDefinitions">A collection of custom type definitions that can be used to resolve custom types when encountering <see cref="ClassProperty"/>.</param>
|
||||||
|
/// <exception cref="ArgumentNullException">Thrown when any of the arguments are null.</exception>
|
||||||
public TmxMapReader(
|
public TmxMapReader(
|
||||||
XmlReader reader,
|
XmlReader reader,
|
||||||
Func<string, Tileset> externalTilesetResolver,
|
Func<string, Tileset> externalTilesetResolver,
|
||||||
|
@ -31,11 +42,13 @@ public class TmxMapReader : IMapReader
|
||||||
_reader.MoveToContent();
|
_reader.MoveToContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public Map ReadMap()
|
public Map ReadMap()
|
||||||
{
|
{
|
||||||
return Tmx.ReadMap(_reader, _externalTilesetResolver, _externalTemplateResolver, _customTypeDefinitions);
|
return Tmx.ReadMap(_reader, _externalTilesetResolver, _externalTemplateResolver, _customTypeDefinitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!disposedValue)
|
if (!disposedValue)
|
||||||
|
@ -59,6 +72,7 @@ public class TmxMapReader : IMapReader
|
||||||
// Dispose(disposing: false);
|
// Dispose(disposing: false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||||
|
|
|
@ -5,6 +5,9 @@ using DotTiled.Model;
|
||||||
|
|
||||||
namespace DotTiled.Serialization.Tmx;
|
namespace DotTiled.Serialization.Tmx;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A tileset reader for the Tiled XML format.
|
||||||
|
/// </summary>
|
||||||
public class TsxTilesetReader : ITilesetReader
|
public class TsxTilesetReader : ITilesetReader
|
||||||
{
|
{
|
||||||
// External resolvers
|
// External resolvers
|
||||||
|
@ -15,6 +18,13 @@ public class TsxTilesetReader : ITilesetReader
|
||||||
|
|
||||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new <see cref="TsxTilesetReader"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An XML reader for reading a Tiled tileset in the Tiled XML format.</param>
|
||||||
|
/// <param name="externalTemplateResolver">A function that resolves external templates given their source.</param>
|
||||||
|
/// <param name="customTypeDefinitions">A collection of custom type definitions that can be used to resolve custom types when encountering <see cref="ClassProperty"/>.</param>
|
||||||
|
/// <exception cref="ArgumentNullException">Thrown when any of the arguments are null.</exception>
|
||||||
public TsxTilesetReader(
|
public TsxTilesetReader(
|
||||||
XmlReader reader,
|
XmlReader reader,
|
||||||
Func<string, Template> externalTemplateResolver,
|
Func<string, Template> externalTemplateResolver,
|
||||||
|
@ -28,8 +38,10 @@ public class TsxTilesetReader : ITilesetReader
|
||||||
_reader.MoveToContent();
|
_reader.MoveToContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public Tileset ReadTileset() => Tmx.ReadTileset(_reader, null, _externalTemplateResolver, _customTypeDefinitions);
|
public Tileset ReadTileset() => Tmx.ReadTileset(_reader, null, _externalTemplateResolver, _customTypeDefinitions);
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!disposedValue)
|
if (!disposedValue)
|
||||||
|
@ -52,6 +64,7 @@ public class TsxTilesetReader : ITilesetReader
|
||||||
// Dispose(disposing: false);
|
// Dispose(disposing: false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||||
|
|
|
@ -5,6 +5,9 @@ using DotTiled.Model;
|
||||||
|
|
||||||
namespace DotTiled.Serialization.Tmx;
|
namespace DotTiled.Serialization.Tmx;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A template reader for the Tiled XML format.
|
||||||
|
/// </summary>
|
||||||
public class TxTemplateReader : ITemplateReader
|
public class TxTemplateReader : ITemplateReader
|
||||||
{
|
{
|
||||||
// Resolvers
|
// Resolvers
|
||||||
|
@ -16,6 +19,14 @@ public class TxTemplateReader : ITemplateReader
|
||||||
|
|
||||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new <see cref="TxTemplateReader"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An XML reader for reading a Tiled template in the Tiled XML format.</param>
|
||||||
|
/// <param name="externalTilesetResolver">A function that resolves external tilesets given their source.</param>
|
||||||
|
/// <param name="externalTemplateResolver">A function that resolves external templates given their source.</param>
|
||||||
|
/// <param name="customTypeDefinitions">A collection of custom type definitions that can be used to resolve custom types when encountering <see cref="ClassProperty"/>.</param>
|
||||||
|
/// <exception cref="ArgumentNullException">Thrown when any of the arguments are null.</exception>
|
||||||
public TxTemplateReader(
|
public TxTemplateReader(
|
||||||
XmlReader reader,
|
XmlReader reader,
|
||||||
Func<string, Tileset> externalTilesetResolver,
|
Func<string, Tileset> externalTilesetResolver,
|
||||||
|
@ -31,8 +42,10 @@ public class TxTemplateReader : ITemplateReader
|
||||||
_reader.MoveToContent();
|
_reader.MoveToContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public Template ReadTemplate() => Tmx.ReadTemplate(_reader, _externalTilesetResolver, _externalTemplateResolver, _customTypeDefinitions);
|
public Template ReadTemplate() => Tmx.ReadTemplate(_reader, _externalTilesetResolver, _externalTemplateResolver, _customTypeDefinitions);
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!disposedValue)
|
if (!disposedValue)
|
||||||
|
@ -55,6 +68,7 @@ public class TxTemplateReader : ITemplateReader
|
||||||
// Dispose(disposing: false);
|
// Dispose(disposing: false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||||
|
|
Loading…
Add table
Reference in a new issue