add encodedpayloadsize
This commit is contained in:
@@ -20,6 +20,10 @@ namespace ndefpclib.records
|
||||
/// <summary> Type of the message. </summary>
|
||||
private MsgType msgType;
|
||||
|
||||
|
||||
/// <summary> Size of the encoded payload. </summary>
|
||||
private int encodedPayloadSize = -1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@@ -145,7 +149,29 @@ namespace ndefpclib.records
|
||||
{
|
||||
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[1] = NDEFRecord.TypeSize;
|
||||
array[2] = (byte)(Payload.Length + this.PayloadPraefix.Length);
|
||||
array[2] = (byte)(this.EncodedPayloadSize + this.PayloadPraefix.Length);
|
||||
array[3] = (byte)this.Type;
|
||||
|
||||
int i = this.HeaderSize;
|
||||
|
||||
Reference in New Issue
Block a user