Did some doc texts

This commit is contained in:
Serraniel 2018-04-06 21:10:46 +02:00
parent 18107c64c7
commit 90268e899b
2 changed files with 116 additions and 13 deletions

View file

@ -5,6 +5,9 @@ using SweetLib.Utils.Extensions;
namespace SweetLib.IO.Classes.Streaming namespace SweetLib.IO.Classes.Streaming
{ {
/// <summary>
/// <see cref="StreamManager"/> wraps some useful methods for custom implementations of object streaming.
/// </summary>
public static class StreamManager public static class StreamManager
{ {
enum StreamedObjectType : ushort // 2 bytes enum StreamedObjectType : ushort // 2 bytes
@ -68,38 +71,91 @@ namespace SweetLib.IO.Classes.Streaming
return buffer; return buffer;
} }
/// <summary>
/// Adds a <see cref="string"/> to a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> to which the <see cref="string"/> will be added.</param>
/// <param name="value"><see cref="string"/> value to add.</param>
public static void SaveToStream(Stream stream, string value) public static void SaveToStream(Stream stream, string value)
{ {
SaveToStream(stream, StreamedObjectType.StringValue, value.AsBytes()); SaveToStream(stream, StreamedObjectType.StringValue, value.AsBytes());
} }
/// <summary>
/// Adds a <see cref="bool"/> to a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> to which the <see cref="bool"/> will be added.</param>
/// <param name="value"><see cref="bool"/> value to add.</param>
public static void SaveToStream(Stream stream, bool value) public static void SaveToStream(Stream stream, bool value)
{ {
SaveToStream(stream, StreamedObjectType.BoolValue, value.AsBytes()); SaveToStream(stream, StreamedObjectType.BoolValue, value.AsBytes());
} }
/// <summary>
/// Adds a <see cref="char"/> to a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> to which the <see cref="char"/> will be added.</param>
/// <param name="value"><see cref="char"/> value to add.</param>
public static void SaveToStream(Stream stream, char value) public static void SaveToStream(Stream stream, char value)
{ {
SaveToStream(stream, StreamedObjectType.CharValue, value.AsBytes()); SaveToStream(stream, StreamedObjectType.CharValue, value.AsBytes());
} }
/// <summary>
/// Adds a <see cref="int"/> to a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> to which the <see cref="int"/> will be added.</param>
/// <param name="value"><see cref="int"/> value to add.</param>
public static void SaveToStream(Stream stream, int value) public static void SaveToStream(Stream stream, int value)
{ {
SaveToStream(stream, StreamedObjectType.IntValue, value.AsBytes()); SaveToStream(stream, StreamedObjectType.IntValue, value.AsBytes());
} }
/// <summary>
/// Adds a <see cref="long"/> to a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> to which the <see cref="long"/> will be added.</param>
/// <param name="value"><see cref="long"/> value to add.</param>
public static void SaveToStream(Stream stream, long value) public static void SaveToStream(Stream stream, long value)
{ {
SaveToStream(stream, StreamedObjectType.LongValue, value.AsBytes()); SaveToStream(stream, StreamedObjectType.LongValue, value.AsBytes());
} }
/// <summary>
/// Adds a <see cref="float"/> to a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> to which the <see cref="float"/> will be added.</param>
/// <param name="value"><see cref="float"/> value to add.</param>
public static void SaveToStream(Stream stream, float value) public static void SaveToStream(Stream stream, float value)
{ {
SaveToStream(stream, StreamedObjectType.FloatValue, value.AsBytes()); SaveToStream(stream, StreamedObjectType.FloatValue, value.AsBytes());
} }
/// <summary>
/// Adds a <see cref="double"/> to a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> to which the <see cref="double"/> will be added.</param>
/// <param name="value"><see cref="double"/> value to add.</param>
public static void SaveToStream(Stream stream, double value) public static void SaveToStream(Stream stream, double value)
{ {
SaveToStream(stream, StreamedObjectType.DoubleValue, value.AsBytes()); SaveToStream(stream, StreamedObjectType.DoubleValue, value.AsBytes());
} }
/// <summary>
/// Adds a <see cref="DateTime"/> to a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> to which the <see cref="DateTime"/> will be added.</param>
/// <param name="value"><see cref="DateTime"/> value to add.</param>
public static void SaveToStream(Stream stream, DateTime value) public static void SaveToStream(Stream stream, DateTime value)
{ {
SaveToStream(stream, StreamedObjectType.DateTimeValue, value.AsBytes()); SaveToStream(stream, StreamedObjectType.DateTimeValue, value.AsBytes());
} }
/// <summary>
/// Adds a <see cref="Stream"/> to a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> to which the <see cref="Stream"/> will be added.</param>
/// <param name="value"><see cref="Stream"/> value to add.</param>
public static void SaveToStream(Stream stream, Stream value, bool resetSourceStream = false) public static void SaveToStream(Stream stream, Stream value, bool resetSourceStream = false)
{ {
if (resetSourceStream) if (resetSourceStream)
@ -110,45 +166,92 @@ namespace SweetLib.IO.Classes.Streaming
SaveToStream(stream, StreamedObjectType.StreamValue, buffer); SaveToStream(stream, StreamedObjectType.StreamValue, buffer);
} }
/// <summary>
/// Loads a <see cref="string"/> from a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> from which the <see cref="string"/> will be loaded.</param>
/// <param name="value">Contains the loaded <see cref="string"/> value.</param>
public static void LoadFromStream(Stream stream, out string value) public static void LoadFromStream(Stream stream, out string value)
{ {
value = LoadFromStream(stream, StreamedObjectType.StringValue).AsString(); value = LoadFromStream(stream, StreamedObjectType.StringValue).AsString();
} }
/// <summary>
/// Loads a <see cref="bool"/> from a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> from which the <see cref="bool"/> will be loaded.</param>
/// <param name="value">Contains the loaded <see cref="bool"/> value.</param>
public static void LoadFromStream(Stream stream, out bool value) public static void LoadFromStream(Stream stream, out bool value)
{ {
value = LoadFromStream(stream, StreamedObjectType.BoolValue).AsBool(); value = LoadFromStream(stream, StreamedObjectType.BoolValue).AsBool();
} }
/// <summary>
/// Loads a <see cref="char"/> from a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> from which the <see cref="char"/> will be loaded.</param>
/// <param name="value">Contains the loaded <see cref="char"/> value.</param>
public static void LoadFromStream(Stream stream, out char value) public static void LoadFromStream(Stream stream, out char value)
{ {
value = LoadFromStream(stream, StreamedObjectType.CharValue).AsChar(); value = LoadFromStream(stream, StreamedObjectType.CharValue).AsChar();
} }
/// <summary>
/// Loads a <see cref="int"/> from a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> from which the <see cref="int"/> will be loaded.</param>
/// <param name="value">Contains the loaded <see cref="int"/> value.</param>
public static void LoadFromStream(Stream stream, out int value) public static void LoadFromStream(Stream stream, out int value)
{ {
value = LoadFromStream(stream, StreamedObjectType.IntValue).AsInt32(); value = LoadFromStream(stream, StreamedObjectType.IntValue).AsInt32();
} }
/// <summary>
/// Loads a <see cref="long"/> from a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> from which the <see cref="long"/> will be loaded.</param>
/// <param name="value">Contains the loaded <see cref="long"/> value.</param>
public static void LoadFromStream(Stream stream, out long value) public static void LoadFromStream(Stream stream, out long value)
{ {
value = LoadFromStream(stream, StreamedObjectType.LongValue).AsInt64(); value = LoadFromStream(stream, StreamedObjectType.LongValue).AsInt64();
} }
/// <summary>
/// Loads a <see cref="string"/> from a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> from which the <see cref="string"/> will be loaded.</param>
/// <param name="value">Contains the loaded <see cref="string"/> value.</param>
public static void LoadFromStream(Stream stream, out float value) public static void LoadFromStream(Stream stream, out float value)
{ {
value = LoadFromStream(stream, StreamedObjectType.FloatValue).AsSingle(); value = LoadFromStream(stream, StreamedObjectType.FloatValue).AsSingle();
} }
/// <summary>
/// Loads a <see cref="double"/> from a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> from which the <see cref="double"/> will be loaded.</param>
/// <param name="value">Contains the loaded <see cref="double"/> value.</param>
public static void LoadFromStream(Stream stream, out double value) public static void LoadFromStream(Stream stream, out double value)
{ {
value = LoadFromStream(stream, StreamedObjectType.DoubleValue).AsDouble(); value = LoadFromStream(stream, StreamedObjectType.DoubleValue).AsDouble();
} }
/// <summary>
/// Loads a <see cref="DateTime"/> from a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> from which the <see cref="DateTime"/> will be loaded.</param>
/// <param name="value">Contains the loaded <see cref="DateTime"/> value.</param>
public static void LoadFromStream(Stream stream, out DateTime value) public static void LoadFromStream(Stream stream, out DateTime value)
{ {
value = LoadFromStream(stream, StreamedObjectType.DateTimeValue).AsDateTime(); value = LoadFromStream(stream, StreamedObjectType.DateTimeValue).AsDateTime();
} }
/// <summary>
/// Loads a <see cref="Stream"/> from a given <see cref="Stream"/>.
/// </summary>
/// <param name="stream"><see cref="Stream"/> from which the <see cref="Stream"/> will be loaded.</param>
/// <param name="value">Contains the loaded <see cref="Stream"/> value.</param>
public static void LoadFromStream(Stream stream, out Stream value) public static void LoadFromStream(Stream stream, out Stream value)
{ {
var buffer = LoadFromStream(stream, StreamedObjectType.StreamValue); var buffer = LoadFromStream(stream, StreamedObjectType.StreamValue);

View file

@ -130,7 +130,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="short"/> type. /// Converts a byte array into a <see cref="short"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -140,7 +140,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="ushort"/> type. /// Converts a byte array into a <see cref="ushort"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -150,7 +150,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="int"/> type. /// Converts a byte array into a <see cref="int"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -160,7 +160,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="uint"/> type. /// Converts a byte array into a <see cref="uint"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -170,7 +170,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="long"/> type. /// Converts a byte array into a <see cref="long"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -180,7 +180,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="ulong"/> type. /// Converts a byte array into a <see cref="ulong"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -190,7 +190,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="float"/> type. /// Converts a byte array into a <see cref="float"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -200,7 +200,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="double"/> type. /// Converts a byte array into a <see cref="double"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -210,7 +210,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="bool"/> type. /// Converts a byte array into a <see cref="bool"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -220,7 +220,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="DateTime"/> type. /// Converts a byte array into a <see cref="DateTime"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -230,7 +230,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="string"/> type. /// Converts a byte array into a <see cref="string"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>
@ -241,7 +241,7 @@ namespace SweetLib.Utils.Extensions
} }
/// <summary> /// <summary>
/// Converts a <see cref="byte[]"/> into a <see cref="char"/> type. /// Converts a byte array into a <see cref="char"/> type.
/// </summary> /// </summary>
/// <param name="bytes">Byte array representation to convert.</param> /// <param name="bytes">Byte array representation to convert.</param>
/// <returns>Converted value.</returns> /// <returns>Converted value.</returns>