2using System.Collections.Generic;
14 private readonly Dictionary<int, string> keywordsDictionary;
21 keywordsDictionary =
new Dictionary<int, string>();
30 public List<SerializationInfo>
Read(Stream serializationStream)
32 var returnValue =
new List<SerializationInfo>();
33 int childCount, valueCount, referenceId;
34 string systemName, enumTypeName;
37 keywordsDictionary.Clear();
38 using (var reader =
new BinaryReader(serializationStream))
40 var totalCount = reader.ReadInt32();
41 for (var counter = 0; counter < totalCount; counter++)
44 info.ReferenceId = reader.ReadInt32();
45 info.TypeName = (string)ReadObject(reader);
47 childCount = reader.ReadInt32();
48 for (var childCounter = 0; childCounter < childCount; childCounter++)
50 systemName = (string)ReadObject(reader);
51 isDirty = (bool)ReadObject(reader);
52 referenceId = (int)ReadObject(reader);
53 info.AddChild(systemName, referenceId, isDirty);
56 valueCount = reader.ReadInt32();
57 for (var valueCounter = 0; valueCounter < valueCount; valueCounter++)
59 systemName = (string)ReadObject(reader);
60 enumTypeName = (string)ReadObject(reader);
61 isDirty = (bool)ReadObject(reader);
62 value = ReadObject(reader);
63 info.AddValue(systemName, value, isDirty,
string.IsNullOrEmpty(enumTypeName) ?
null : enumTypeName);
65 returnValue.Add(info);
72 private object ReadObject(BinaryReader reader)
78 return reader.ReadBoolean();
80 return reader.ReadChar();
82 return reader.ReadSByte();
84 return reader.ReadByte();
86 return reader.ReadInt16();
88 return reader.ReadUInt16();
90 return reader.ReadInt32();
92 return reader.ReadUInt32();
94 return reader.ReadInt64();
96 return reader.ReadUInt64();
98 return reader.ReadSingle();
100 return reader.ReadDouble();
102 var totalBits = reader.ReadInt32();
103 var decimalBits =
new int[totalBits];
104 for (var counter = 0; counter < totalBits; counter++)
106 decimalBits[counter] = reader.ReadInt32();
108 return new Decimal(decimalBits);
110 return new DateTime(reader.ReadInt64());
112 return reader.ReadString();
114 return new TimeSpan(reader.ReadInt64());
116 return new DateTimeOffset(reader.ReadInt64(),
new TimeSpan(reader.ReadInt64()));
118 return new Guid(reader.ReadBytes(16));
120 return reader.ReadBytes(reader.ReadInt32());
122 var count = reader.ReadInt32();
123 var result =
new byte[count][];
124 for (
int i = 0; i < count; i++)
125 result[i] = reader.ReadBytes(reader.ReadInt32());
128 return reader.ReadChars(reader.ReadInt32());
130 var returnValue =
new List<int>();
131 var total = reader.ReadInt32();
132 for (var counter = 0; counter < total; counter++)
134 returnValue.Add(reader.ReadInt32());
140 var systemString = reader.ReadString();
141 keywordsDictionary.Add(reader.ReadInt32(), systemString);
144 return keywordsDictionary[reader.ReadInt32()];
A strongly-typed resource class, for looking up localized strings, etc.
static string UnandledKNownTypeException
Looks up a localized string similar to Unhandled CSLA Known type was found.
This is a legacy version of CslaBinaryReader.
CslaLegacyBinaryReader()
Creates new instance of CslaLegacyBinaryReader
List< SerializationInfo > Read(Stream serializationStream)
Read a data from a stream, typically MemoryStream, and convert it into a list of SerializationInfo ob...
Object containing the serialization data for a specific object.
Represents a reader class that can be used to read the data sent across the wire in byte array format...
CslaKnownTypes
This enumeration contains the list of known types that CslaBinaryReader and CslaBinaryWriterknow abou...