add encodedpayloadsize
This commit is contained in:
@@ -20,6 +20,10 @@ namespace ndefpclib.records
|
|||||||
/// <summary> Type of the message. </summary>
|
/// <summary> Type of the message. </summary>
|
||||||
private MsgType msgType;
|
private MsgType msgType;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary> Size of the encoded payload. </summary>
|
||||||
|
private int encodedPayloadSize = -1;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@@ -35,7 +39,7 @@ namespace ndefpclib.records
|
|||||||
/// <param name="array"> The array. </param>
|
/// <param name="array"> The array. </param>
|
||||||
/// <param name="headerSize"> The size of the header. </param>
|
/// <param name="headerSize"> The size of the header. </param>
|
||||||
/// <param name="index"> (Optional) zero-based index of the. </param>
|
/// <param name="index"> (Optional) zero-based index of the. </param>
|
||||||
public NDEFRecord(byte[] array, int headerSize,int index = 0)
|
public NDEFRecord(byte[] array, int headerSize, int index = 0)
|
||||||
{
|
{
|
||||||
this.msgType = MsgType.GetType(array, index);
|
this.msgType = MsgType.GetType(array, index);
|
||||||
this.HeaderSize = headerSize;
|
this.HeaderSize = headerSize;
|
||||||
@@ -145,7 +149,29 @@ namespace ndefpclib.records
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this.HeaderSize + this.Payload.Length + this.PayloadPraefix.Length;
|
return this.HeaderSize + this.EncodedPayloadSize + this.PayloadPraefix.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Gets the size of the encoded payload. </summary>
|
||||||
|
/// <value> The size of the encoded payload. </value>
|
||||||
|
public int EncodedPayloadSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (this.encodedPayloadSize >= 0)
|
||||||
|
{
|
||||||
|
return this.encodedPayloadSize;
|
||||||
|
}
|
||||||
|
else if (this.msgType != null && this.encodedPayloadSize < 0)
|
||||||
|
{
|
||||||
|
this.encodedPayloadSize = this.msgType.Encoder.GetByteCount(this.Payload);
|
||||||
|
return this.encodedPayloadSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.Payload.Length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace ndefpclib.records
|
|||||||
|
|
||||||
array[0] = this.FormatFlags;
|
array[0] = this.FormatFlags;
|
||||||
array[1] = NDEFRecord.TypeSize;
|
array[1] = NDEFRecord.TypeSize;
|
||||||
array[2] = (byte)(Payload.Length + this.PayloadPraefix.Length);
|
array[2] = (byte)(this.EncodedPayloadSize + this.PayloadPraefix.Length);
|
||||||
array[3] = (byte)this.Type;
|
array[3] = (byte)this.Type;
|
||||||
|
|
||||||
int i = this.HeaderSize;
|
int i = this.HeaderSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user