protected override bool CreateFromSourceBytes(ArraySegment <byte> bytes) { int itemCount = System.BitConverter.ToInt32(bytes.Array, bytes.Offset); Dictionary <int, T> dict = new Dictionary <int, T>(); int header = sizeof(int); // item count int index = header; for (int i = 0; i < itemCount; i++) { int key = System.BitConverter.ToInt32(bytes.Array, index + bytes.Offset); index += sizeof(int); T obj = new T(); if (!obj.CreateFromBytes(bytes.ArraySegmentFrom(index))) { m_value.Clear(); return(false); } index += obj.GetByteCount(); dict[key] = obj; } m_value = dict; return(true); }
public bool CreateFromBytes(ArraySegment <byte> bytes) { if (bytes.At(0) == (byte)SerializationID()) { if (CreateFromSourceBytes(bytes.ArraySegmentFrom(1))) { return(true); } } return(false); }
protected override bool CreateFromSourceBytes(ArraySegment <byte> bytes) { int index = 0; for (int i = 0; i < m_serializableMembers.Count; i++) { if (!m_serializableMembers[i].CreateFromBytes(bytes.ArraySegmentFrom(index))) { return(false); } index += m_serializableMembers[i].GetByteCount(); } return(true); }