Skip to content

Commit

Permalink
Updated xml doc
Browse files Browse the repository at this point in the history
RolandKoenig committed Sep 20, 2020
1 parent db22efa commit 2658b42
Showing 14 changed files with 333 additions and 3 deletions.
205 changes: 203 additions & 2 deletions MessageCommunicator/MessageCommunicator.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public abstract class ByteStreamHandler : IByteStreamHandler
public abstract string RemoteEndpointDescription { get; }

/// <summary>
/// A custom logger. If set, this delegate will be called with all relevant events.
/// Gets or sets a custom logger. If set, this delegate will be called with all relevant events.
/// </summary>
public IMessageCommunicatorLogger? Logger { get; set; }

4 changes: 4 additions & 0 deletions MessageCommunicator/_MessageRecognizer/IMessageRecognizer.cs
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@

namespace MessageCommunicator
{
/// <summary>
/// A <see cref="IMessageRecognizer"/> is responsible to recognize incoming messages and for formatting
/// outgoing messages.
/// </summary>
public interface IMessageRecognizer
{
/// <summary>
Original file line number Diff line number Diff line change
@@ -3,6 +3,9 @@

namespace MessageCommunicator
{
/// <summary>
/// This exception type is thrown during message recognition in an <see cref="IMessageRecognizer"/> implementation.
/// </summary>
public class MessageRecognitionException : Exception
{
public MessageRecognitionException()
13 changes: 13 additions & 0 deletions MessageCommunicator/_MessageRecognizer/MessageRecognizer.cs
Original file line number Diff line number Diff line change
@@ -3,12 +3,25 @@

namespace MessageCommunicator
{
/// <summary>
/// A <see cref="MessageRecognizer"/> is responsible to recognize incoming messages and for formatting
/// outgoing messages.
/// </summary>
public abstract class MessageRecognizer : IMessageRecognizer
{
/// <summary>
/// Gets or sets the <see cref="IByteStreamHandler"/> implementation to which to forward messages to be sent.
/// </summary>
public IByteStreamHandler? ByteStreamHandler { get; set; }

/// <summary>
/// Gets or sets the <see cref="IMessageReceiveHandler"/> implementation to which to forward all recognized messages.
/// </summary>
public IMessageReceiveHandler? ReceiveHandler { get; set; }

/// <summary>
/// Gets or sets a custom logger. If set, this delegate will be called with all relevant events.
/// </summary>
public IMessageCommunicatorLogger? Logger { get; set; }

/// <summary>
Original file line number Diff line number Diff line change
@@ -4,8 +4,15 @@

namespace MessageCommunicator
{
/// <summary>
/// Encapsulates all settings for an <see cref="IMessageRecognizer"/> implementation.
/// </summary>
public abstract class MessageRecognizerSettings
{
/// <summary>
/// Factory method which creates an <see cref="IMessageRecognizer"/> implementation.
/// </summary>
/// <returns>The created <see cref="IMessageRecognizer"/> implementation.</returns>
public abstract MessageRecognizer CreateMessageRecognizer();
}
}
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@

namespace MessageCommunicator
{
/// <summary>
/// This <see cref="MessageRecognizer"/> implements a custom messages style of the MessageCommunicator
/// project.
/// </summary>
public class DefaultMessageRecognizer : MessageRecognizer
{
private const char SYMBOL_START = '<';
@@ -15,6 +19,10 @@ public class DefaultMessageRecognizer : MessageRecognizer
private Decoder _decoder;
private StringBuffer _receiveStringBuffer;

/// <summary>
/// Creates a new <see cref="DefaultMessageRecognizer"/> instance.
/// </summary>
/// <param name="encoding">The <see cref="Encoding"/> to be used when convert characters to/from bytes.</param>
public DefaultMessageRecognizer(Encoding encoding)
{
_encoding = encoding;
Original file line number Diff line number Diff line change
@@ -4,10 +4,20 @@

namespace MessageCommunicator
{
/// <summary>
/// This class provides all settings for <see cref="DefaultMessageRecognizer"/>.
/// </summary>
public class DefaultMessageRecognizerSettings : MessageRecognizerSettings
{
/// <summary>
/// Gets or sets the <see cref="Encoding"/> to be used when convert characters to/from bytes.
/// </summary>
public Encoding Encoding { get; set; }

/// <summary>
/// Creates a new <see cref="DefaultMessageRecognizerSettings"/> instance.
/// </summary>
/// <param name="encoding">The <see cref="Encoding"/> to be used when convert characters to/from bytes.</param>
public DefaultMessageRecognizerSettings(Encoding encoding)
{
this.Encoding = encoding;
Original file line number Diff line number Diff line change
@@ -6,13 +6,21 @@

namespace MessageCommunicator
{
/// <summary>
/// This <see cref="MessageRecognizer"/> implementation recognizes messages with one or more end symbols.
/// </summary>
public class EndSymbolsMessageRecognizer : MessageRecognizer
{
private Encoding _encoding;
private Decoder _decoder;
private string _endSymbols;
private StringBuffer _receiveStringBuffer;

/// <summary>
/// Creates a new <see cref="EndSymbolsMessageRecognizer"/> instance.
/// </summary>
/// <param name="encoding">The <see cref="Encoding"/> to be used when convert characters to/from bytes.</param>
/// <param name="endSymbols">The end symbols of received/sent messages.</param>
public EndSymbolsMessageRecognizer(Encoding encoding, string endSymbols)
{
if (string.IsNullOrEmpty(endSymbols))
@@ -64,6 +72,7 @@ protected override Task<bool> SendInternalAsync(IByteStreamHandler byteStreamHan
}
}

/// <inheritdoc />
public override void OnReceivedBytes(bool isNewConnection, ArraySegment<byte> receivedSegment)
{
// Clear receive buffer on new connections
Original file line number Diff line number Diff line change
@@ -4,12 +4,26 @@

namespace MessageCommunicator
{
/// <summary>
/// This class provides all settings for <see cref="EndSymbolsMessageRecognizer"/>.
/// </summary>
public class EndSymbolsMessageRecognizerSettings : MessageRecognizerSettings
{
/// <summary>
/// Gets or sets the <see cref="Encoding"/> to be used when convert characters to/from bytes.
/// </summary>
public Encoding Encoding { get; set; }

/// <summary>
/// Gets or sets the end symbols of received/sent messages.
/// </summary>
public string EndSymbols { get; set; }

/// <summary>
/// Creates a new <see cref="EndSymbolsMessageRecognizerSettings"/> instance.
/// </summary>
/// <param name="encoding">The <see cref="Encoding"/> to be used when convert characters to/from bytes.</param>
/// <param name="endSymbols">The end symbols of received/sent messages.</param>
public EndSymbolsMessageRecognizerSettings(Encoding encoding, string endSymbols)
{
this.Encoding = encoding;
Original file line number Diff line number Diff line change
@@ -6,6 +6,10 @@

namespace MessageCommunicator
{
/// <summary>
/// This <see cref="MessageRecognizer"/> implementation recognizes messages with one or more end symbols and
/// a fixed length.
/// </summary>
public class FixedLengthAndEndSymbolsMessageRecognizer : MessageRecognizer
{
private Encoding _encoding;
@@ -16,6 +20,13 @@ public class FixedLengthAndEndSymbolsMessageRecognizer : MessageRecognizer
private char _fillSymbol;
private StringBuffer _receiveStringBuffer;

/// <summary>
/// Creates a new <see cref="FixedLengthAndEndSymbolsMessageRecognizer"/> instance.
/// </summary>
/// <param name="encoding">The <see cref="Encoding"/> to be used when convert characters to/from bytes.</param>
/// <param name="endSymbols">The end symbols of received/sent messages.</param>
/// <param name="lengthIncludingEndSymbols">Total length of received/sent messages.</param>
/// <param name="fillSymbol">Fill symbol for messages shorter than the fixed length.</param>
public FixedLengthAndEndSymbolsMessageRecognizer(Encoding encoding, string endSymbols, int lengthIncludingEndSymbols, char fillSymbol)
{
_encoding = encoding;
@@ -82,6 +93,7 @@ protected override Task<bool> SendInternalAsync(IByteStreamHandler byteStreamHan
}
}

/// <inheritdoc />
public override void OnReceivedBytes(bool isNewConnection, ArraySegment<byte> receivedSegment)
{
// Clear receive buffer on new connections
Original file line number Diff line number Diff line change
@@ -4,16 +4,38 @@

namespace MessageCommunicator
{
/// <summary>
/// This class provides all settings for <see cref="FixedLengthAndEndSymbolsMessageRecognizer"/>.
/// </summary>
public class FixedLengthAndEndSymbolsMessageRecognizerSettings : MessageRecognizerSettings
{
/// <summary>
/// Gets or sets the <see cref="Encoding"/> to be used when convert characters to/from bytes.
/// </summary>
public Encoding Encoding { get; set; }

/// <summary>
/// Gets or sets the end symbols of received/sent messages.
/// </summary>
public string EndSymbols { get; set; }

/// <summary>
/// Gets or sets the total length of received/sent messages.
/// </summary>
public int LengthIncludingEndSymbols { get; set; }

/// <summary>
/// Gets or sets the fill symbol for messages shorter than the fixed length.
/// </summary>
public char FillSymbol { get; set; }

/// <summary>
/// Creates a new <see cref="FixedLengthAndEndSymbolsMessageRecognizerSettings"/> instance.
/// </summary>
/// <param name="encoding">The <see cref="Encoding"/> to be used when convert characters to/from bytes.</param>
/// <param name="endSymbols">The end symbols of received/sent messages.</param>
/// <param name="lengthIncludingEndSymbols">Total length of received/sent messages.</param>
/// <param name="fillSymbol">Fill symbol for messages shorter than the fixed length.</param>
public FixedLengthAndEndSymbolsMessageRecognizerSettings(Encoding encoding, string endSymbols, int lengthIncludingEndSymbols, char fillSymbol)
{
this.Encoding = encoding;
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@

namespace MessageCommunicator
{
/// <summary>
/// This <see cref="MessageRecognizer"/> implementation recognizes messages with one or more start and end symbols.
/// </summary>
public class StartAndEndSymbolsRecognizer : MessageRecognizer
{
private Encoding _encoding;
@@ -14,6 +17,12 @@ public class StartAndEndSymbolsRecognizer : MessageRecognizer
private string _endSymbols;
private StringBuffer _receiveStringBuffer;

/// <summary>
/// Creates a new <see cref="EndSymbolsMessageRecognizer"/> instance.
/// </summary>
/// <param name="encoding">The <see cref="Encoding"/> to be used when convert characters to/from bytes.</param>
/// <param name="startSymbols">The start symbols of received/sent messages.</param>
/// <param name="endSymbols">The end symbols of received/sent messages.</param>
public StartAndEndSymbolsRecognizer(Encoding encoding, string startSymbols, string endSymbols)
{
_encoding = encoding;
Original file line number Diff line number Diff line change
@@ -4,14 +4,32 @@

namespace MessageCommunicator
{
/// <summary>
/// This class provides all settings for <see cref="StartAndEndSymbolsRecognizer"/>.
/// </summary>
public class StartAndEndSymbolsRecognizerSettings : MessageRecognizerSettings
{
/// <summary>
/// Gets or sets the <see cref="Encoding"/> to be used when convert characters to/from bytes.
/// </summary>
public Encoding Encoding { get; set; }

/// <summary>
/// Gets or sets the start symbols of received/sent messages.
/// </summary>
public string StartSymbols { get; set; }

/// <summary>
/// Gets or sets the end symbols of received/sent messages.
/// </summary>
public string EndSymbols { get; set; }

/// <summary>
/// Creates a new <see cref="StartAndEndSymbolsRecognizerSettings"/> instance.
/// </summary>
/// <param name="encoding">The <see cref="Encoding"/> to be used when convert characters to/from bytes.</param>
/// <param name="startSymbols">The start symbols of received/sent messages.</param>
/// <param name="endSymbols">The end symbols of received/sent messages.</param>
public StartAndEndSymbolsRecognizerSettings(Encoding encoding, string startSymbols, string endSymbols)
{
this.Encoding = encoding;

0 comments on commit 2658b42

Please sign in to comment.