3using System.Collections.Generic;
14 private readonly Dictionary<int, string> keywordsDictionary;
24 keywordsDictionary =
new Dictionary<int, string>();
33 public List<SerializationInfo>
Read(Stream serializationStream)
35 var returnValue =
new List<SerializationInfo>();
36 int childCount, valueCount, referenceId;
37 string systemName, enumTypeName;
40 this.keywordsDictionary.Clear();
42 using (var reader =
new BinaryReader(serializationStream))
44 var totalCount = reader.ReadInt32();
45 for (var counter = 0; counter < totalCount; counter++)
49 ReferenceId = reader.ReadInt32(),
50 TypeName = ReadString(reader)
53 childCount = reader.ReadInt32();
54 for (var childCounter = 0; childCounter < childCount; childCounter++)
56 systemName = ReadString(reader);
57 isDirty = reader.ReadBoolean();
58 referenceId = reader.ReadInt32();
59 info.AddChild(systemName, referenceId, isDirty);
62 valueCount = reader.ReadInt32();
63 for (var valueCounter = 0; valueCounter < valueCount; valueCounter++)
65 systemName = ReadString(reader);
66 enumTypeName = ReadString(reader);
67 isDirty = reader.ReadBoolean();
68 value = ReadObject(reader);
69 info.AddValue(systemName, value, isDirty,
string.IsNullOrEmpty(enumTypeName) ?
null : enumTypeName);
71 returnValue.Add(info);
78 private string ReadString(BinaryReader reader) =>
81 private string ReadString(BinaryReader reader,
CslaKnownTypes knownType)
86 return reader.ReadString();
88 var systemString = reader.ReadString();
89 this.keywordsDictionary.Add(reader.ReadInt32(), systemString);
92 return this.keywordsDictionary[reader.ReadInt32()];
98 private object ReadObject(BinaryReader reader)
104 using (MemoryStream arrayBuffer =
new MemoryStream(reader.ReadBytes(reader.ReadInt32())))
107 var obj = formatter.Deserialize(arrayBuffer);
111 return reader.ReadBoolean();
113 return reader.ReadChar();
115 return reader.ReadSByte();
117 return reader.ReadByte();
119 return reader.ReadInt16();
121 return reader.ReadUInt16();
123 return reader.ReadInt32();
125 return reader.ReadUInt32();
127 return reader.ReadInt64();
129 return reader.ReadUInt64();
131 return reader.ReadSingle();
133 return reader.ReadDouble();
135 var decimalBits =
new int[4];
136 for (var counter = 0; counter < 4; counter++)
138 decimalBits[counter] = reader.ReadInt32();
140 return new decimal(decimalBits);
142 return new DateTime(reader.ReadInt64());
144 return new TimeSpan(reader.ReadInt64());
148 return new Guid(reader.ReadBytes(16));
150 return reader.ReadBytes(reader.ReadInt32());
152 var count = reader.ReadInt32();
153 var result =
new byte[count][];
154 for (
int i = 0; i < count; i++)
155 result[i] = reader.ReadBytes(reader.ReadInt32());
158 return reader.ReadChars(reader.ReadInt32());
160 var total = reader.ReadInt32();
161 var buffer =
new int[total];
162 for (var counter = 0; counter < total; counter++)
164 buffer[counter] = reader.ReadInt32();
166 return new List<int>(buffer);
172 return ReadString(reader, knownType);
Provides consistent context information between the client and server DataPortal objects.
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 class that is responsible for deserializing SerializationInfo objects for receiving the dat...
CslaBinaryReader(ApplicationContext applicationContext)
Creates new instance of CslaBinaryReader
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...
@ DateTimeOffset
Date/time plus time zone / DateTimeOffset
@ TimeSpan
TimeSpan - time span
@ Guid
Globally unique identifier / Guid