public int Deserialize(byte[] ropBytes, int startIndex)
{
int index = startIndex;
this.RopId = ropBytes[index++];
this.InputHandleIndex = ropBytes[index++];
this.ReturnValue = (uint)BitConverter.ToInt32(ropBytes, index);
index += sizeof(uint);
// Only success response has below fields
if (this.ReturnValue == 0)
{
this.AddressTypeCount = (ushort)BitConverter.ToInt16(ropBytes, index);
index += sizeof(ushort);
this.AddressTypeSize = (ushort)BitConverter.ToInt16(ropBytes, index);
index += sizeof(ushort);
this.AddressTypes = new List<string>();
int start = index;
int end = index;
for (int i = index; i < index + this.AddressTypeSize; i++)
{
// Skip non-nulls
if (0 != ropBytes[i])
{
continue;
}
// Null-terminator found
end = i;
string temp = Encoding.ASCII.GetString(ropBytes, start, (end - start) + 1);
this.AddressTypes.Add(temp);
start = ++end;
}
index += this.AddressTypeSize;
}
return index - startIndex;
}
}