mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 20:24:57 +00:00
chore: move all files to file-scoped namespace
This commit is contained in:
@@ -1,81 +1,80 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace PepperDash.Core.Intersystem.Tokens
|
||||
namespace PepperDash.Core.Intersystem.Tokens;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an XSigSerialToken
|
||||
/// </summary>
|
||||
public sealed class XSigSerialToken : XSigToken
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an XSigSerialToken
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public sealed class XSigSerialToken : XSigToken
|
||||
/// <param name="index"></param>
|
||||
/// <param name="value"></param>
|
||||
public XSigSerialToken(int index, string value)
|
||||
: base(index)
|
||||
{
|
||||
private readonly string _value;
|
||||
// 10-bits available for serial encoded data
|
||||
if (index >= 1024 || index < 0)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="value"></param>
|
||||
public XSigSerialToken(int index, string value)
|
||||
: base(index)
|
||||
{
|
||||
// 10-bits available for serial encoded data
|
||||
if (index >= 1024 || index < 0)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
_value = value;
|
||||
}
|
||||
|
||||
_value = value;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override XSigTokenType TokenType
|
||||
{
|
||||
get { return XSigTokenType.Serial; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override XSigTokenType TokenType
|
||||
{
|
||||
get { return XSigTokenType.Serial; }
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override byte[] GetBytes()
|
||||
{
|
||||
var serialBytes = String.IsNullOrEmpty(Value) ? new byte[0] : Encoding.GetEncoding(28591).GetBytes(Value);
|
||||
|
||||
var xsig = new byte[serialBytes.Length + 3];
|
||||
xsig[0] = (byte)(0xC8 | (Index - 1 >> 7));
|
||||
xsig[1] = (byte)((Index - 1) & 0x7F);
|
||||
xsig[xsig.Length - 1] = 0xFF;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override byte[] GetBytes()
|
||||
{
|
||||
var serialBytes = String.IsNullOrEmpty(Value) ? new byte[0] : Encoding.GetEncoding(28591).GetBytes(Value);
|
||||
|
||||
var xsig = new byte[serialBytes.Length + 3];
|
||||
xsig[0] = (byte)(0xC8 | (Index - 1 >> 7));
|
||||
xsig[1] = (byte)((Index - 1) & 0x7F);
|
||||
xsig[xsig.Length - 1] = 0xFF;
|
||||
Buffer.BlockCopy(serialBytes, 0, xsig, 2, serialBytes.Length);
|
||||
return xsig;
|
||||
}
|
||||
|
||||
Buffer.BlockCopy(serialBytes, 0, xsig, 2, serialBytes.Length);
|
||||
return xsig;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="offset"></param>
|
||||
/// <returns></returns>
|
||||
public override XSigToken GetTokenWithOffset(int offset)
|
||||
{
|
||||
if (offset == 0) return this;
|
||||
return new XSigSerialToken(Index + offset, Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="offset"></param>
|
||||
/// <returns></returns>
|
||||
public override XSigToken GetTokenWithOffset(int offset)
|
||||
{
|
||||
if (offset == 0) return this;
|
||||
return new XSigSerialToken(Index + offset, Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Index + " = \"" + Value + "\"";
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Index + " = \"" + Value + "\"";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user