private static void ReadItem(byte[] data, int offset, out int readed, out string name, out int dataLength, out HtspMessageItemType type) { type = (HtspMessageItemType)data[offset]; offset++; var nameLength = data[offset]; offset++; var d = new byte[4]; Array.Copy(data, offset, d, 0, 4); dataLength = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(d, 0)); offset += 4; name = ""; if (nameLength > 0) { name = Encoding.UTF8.GetString(data, offset, nameLength); } readed = 1 + 1 + 4 + nameLength; }
public SerializerBase GetSerializerForType(HtspMessageItemType type) { return(_serializerByType.GetOrAdd(type, t => { switch (t) { case HtspMessageItemType.S64: return GetSerializerForType(typeof(long?)); case HtspMessageItemType.Str: return GetSerializerForType(typeof(string)); case HtspMessageItemType.Bin: return GetSerializerForType(typeof(byte[])); case HtspMessageItemType.List: return GetSerializerForType(typeof(IEnumerable)); case HtspMessageItemType.Map: return GetSerializerForType(typeof(DynamicMessageItem)); } throw new HtspMessageException("chyba"); })); }
internal SerializerBase GetSerializer(HtspMessageItemType type) { return(_serializerFactory.GetSerializerForType(type)); }