本文整理汇总了C#中Deserializer.Read方法的典型用法代码示例。如果您正苦于以下问题:C# Deserializer.Read方法的具体用法?C# Deserializer.Read怎么用?C# Deserializer.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deserializer
的用法示例。
在下文中一共展示了Deserializer.Read方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public override void Deserialize(Deserializer deserializer)
{
base.Deserialize(deserializer);
var touched = new Capo<bool>(fingerprint, tag.Offset);
if (touched[0])
{
deserializer.Read(out foo_);
}
if (touched[1])
{
deserializer.Read(out bar_);
}
}
示例2: TestFloat32
public void TestFloat32()
{
//using (var stream = new MemoryStream())
{
float f;
Buffer stream = new Buffer();
Serializer serializer = new Serializer(stream);
Deserializer deserializer = new Deserializer(stream);
// Boundary value tests
serializer.Write(0.0F);
serializer.Write(Single.Epsilon);
serializer.Write(Single.MinValue);
serializer.Write(Single.MaxValue);
serializer.Write(Single.NegativeInfinity);
serializer.Write(Single.PositiveInfinity);
serializer.Write(Single.NaN);
stream.Rewind();
//stream.Seek(0, SeekOrigin.Begin);
deserializer.Read(out f);
Assert.AreEqual(0.0F, f);
deserializer.Read(out f);
Assert.AreEqual(Single.Epsilon, f);
deserializer.Read(out f);
Assert.AreEqual(Single.MinValue, f);
deserializer.Read(out f);
Assert.AreEqual(Single.MaxValue, f);
deserializer.Read(out f);
Assert.AreEqual(Single.NegativeInfinity, f);
deserializer.Read(out f);
Assert.AreEqual(Single.PositiveInfinity, f);
deserializer.Read(out f);
Assert.AreEqual(Single.NaN, f);
stream.Trim();
//stream.SetLength(0);
// Intermediate value tests
serializer.Write(0.001234F);
serializer.Write(8765.4321F);
stream.Rewind();
//stream.Seek(0, SeekOrigin.Begin);
deserializer.Read(out f);
Assert.AreEqual(0.001234F, f);
deserializer.Read(out f);
Assert.AreEqual(8765.4321F, f);
}
}
示例3: Init
void IFastSerializable.FromStream(Deserializer deserializer)
{
deserializer.Read(out majorVersion);
deserializer.Read(out minorVersion);
format = (ManifestEnvelope.ManifestFormats) deserializer.ReadInt();
int count = deserializer.ReadInt();
serializedManifest = new byte[count];
for (int i = 0; i < count; i++)
serializedManifest[i] = deserializer.ReadByte();
Init();
}
示例4:
void IFastSerializable.FromStream(Deserializer deserializer)
{
int count;
deserializer.Read(out count);
for (int i = 0; i < count; i++)
{
ProviderManifest provider;
deserializer.Read(out provider);
providers.Add(provider.Guid, provider);
}
}
示例5: TestVariableLengthInt64
public void TestVariableLengthInt64()
{
//using (var stream = new MemoryStream())
{
long l, bytes;
Buffer stream = new Buffer();
Serializer serializer = new Serializer(stream);
Deserializer deserializer = new Deserializer(stream);
// Boundary value tests
serializer.Write(0L);
serializer.Write(-1L);
serializer.Write(Int64.MaxValue);
serializer.Write(Int64.MinValue);
stream.Rewind();
//stream.Seek(0, SeekOrigin.Begin);
bytes = deserializer.Read(out l);
Assert.AreEqual(1, bytes);
Assert.AreEqual(0L, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(1, bytes);
Assert.AreEqual(-1L, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(10, bytes);
Assert.AreEqual(Int64.MaxValue, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(10, bytes);
Assert.AreEqual(Int64.MinValue, l);
stream.Trim();
//stream.SetLength(0);
// Intermediate value tests
serializer.Write(0x00003f80L >> 1); // 2
serializer.Write(0x001fc000L >> 1); // 3
serializer.Write(0x0fe00000L >> 1); // 4
serializer.Write(0x00000007f0000000L >> 1); // 5
serializer.Write(0x000003f800000000L >> 1); // 6
serializer.Write(0x0001fc0000000000L >> 1); // 7
serializer.Write(0x00fe000000000000L >> 1); // 8
serializer.Write(0x7f00000000000000L >> 1); // 9
stream.Rewind();
//stream.Seek(0, SeekOrigin.Begin);
bytes = deserializer.Read(out l);
Assert.AreEqual(2, bytes);
Assert.AreEqual(0x00003f80L >> 1, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(3, bytes);
Assert.AreEqual(0x001fc000L >> 1, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(4, bytes);
Assert.AreEqual(0x0fe00000L >> 1, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(5, bytes);
Assert.AreEqual(0x00000007f0000000L >> 1, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(6, bytes);
Assert.AreEqual(0x000003f800000000L >> 1, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(7, bytes);
Assert.AreEqual(0x0001fc0000000000L >> 1, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(8, bytes);
Assert.AreEqual(0x00fe000000000000L >> 1, l);
bytes = deserializer.Read(out l);
Assert.AreEqual(9, bytes);
Assert.AreEqual(0x7f00000000000000L >> 1, l);
}
}
示例6: TestVariableLengthInt32
public void TestVariableLengthInt32()
{
//using (var stream = new MemoryStream())
{
int i, bytes;
Buffer stream = new Buffer();
Serializer serializer = new Serializer(stream);
Deserializer deserializer = new Deserializer(stream);
// Boundary value tests
serializer.Write(0);
serializer.Write(-1);
serializer.Write(Int32.MaxValue);
serializer.Write(Int32.MinValue);
stream.Rewind();
//stream.Seek(0, SeekOrigin.Begin);
bytes = deserializer.Read(out i);
Assert.AreEqual(1, bytes);
Assert.AreEqual(0, i);
bytes = deserializer.Read(out i);
Assert.AreEqual(1, bytes);
Assert.AreEqual(-1, i);
bytes = deserializer.Read(out i);
Assert.AreEqual(5, bytes);
Assert.AreEqual(Int32.MaxValue, i);
bytes = deserializer.Read(out i);
Assert.AreEqual(5, bytes);
Assert.AreEqual(Int32.MinValue, i);
stream.Trim();
//stream.SetLength(0);
// Intermediate value tests
serializer.Write(0x00003f80 >> 1); // 2
serializer.Write(0x001fc000 >> 1); // 3
serializer.Write(0x0fe00000 >> 1); // 4
stream.Rewind();
//stream.Seek(0, SeekOrigin.Begin);
bytes = deserializer.Read(out i);
Assert.AreEqual(2, bytes);
Assert.AreEqual(0x00003f80 >> 1, i);
bytes = deserializer.Read(out i);
Assert.AreEqual(3, bytes);
Assert.AreEqual(0x001fc000 >> 1, i);
bytes = deserializer.Read(out i);
Assert.AreEqual(4, bytes);
Assert.AreEqual(0x0fe00000 >> 1, i);
}
}
示例7: used
void IFastSerializable.FromStream(Deserializer deserializer)
{
// We mark the end of this set of variables so we can add to the end of it, since there is a
// good chance we will have to change it.
ForwardReference endOfKernelNameMap = deserializer.ReadForwardReference();
int version; deserializer.Read(out version); // Not used (yet).
int numDrives; deserializer.Read(out numDrives);
driveNames = new string[numDrives];
kernelNameForDrives = new string[numDrives];
for (int i = 0; i < numDrives; i++)
{
deserializer.Read(out driveNames[i]);
deserializer.Read(out kernelNameForDrives[i]);
}
deserializer.Read(out windows);
deserializer.Read(out systemRoot);
deserializer.Goto(endOfKernelNameMap); // Skip any fields added in later versions.
int count; deserializer.Read(out count);
Debug.Assert(count >= 0);
deserializer.Log("<Marker name=\"ProcessIDForThread\"/ count=\"" + count + "\">");
for (int i = 0; i < count; i++)
{
long key; deserializer.Read(out key);
long startTime100ns; deserializer.Read(out startTime100ns);
int value; deserializer.Read(out value);
threadIDtoProcessID.Add((Address)key, startTime100ns, value);
}
deserializer.Read(out count);
Debug.Assert(count >= 0);
deserializer.Log("<Marker name=\"fileIDToName\"/ count=\"" + count + "\">");
for (int i = 0; i < count; i++)
{
long key; deserializer.Read(out key);
long startTime100ns; deserializer.Read(out startTime100ns);
string value; deserializer.Read(out value);
fileIDToName.Add((Address)key, startTime100ns, value);
}
}
示例8:
void IFastSerializable.FromStream(Deserializer deserializer)
{
int count;
deserializer.Read(out count);
m_templates = new List<DynamicTraceEventData>(count);
for (int i = 0; i < count; i++)
{
DynamicTraceEventData template;
deserializer.Read(out template);
m_templates.Add(template);
}
}
示例9: TestFloat64
public void TestFloat64()
{
//using (var stream = new MemoryStream())
{
double d;
var stream = new x2.Buffer();
Serializer serializer = new Serializer(stream);
Deserializer deserializer = new Deserializer(stream);
// Boundary value tests
serializer.Write(0.0);
serializer.Write(Double.Epsilon);
serializer.Write(Double.MinValue);
serializer.Write(Double.MaxValue);
serializer.Write(Double.NegativeInfinity);
serializer.Write(Double.PositiveInfinity);
serializer.Write(Double.NaN);
stream.Rewind();
//stream.Seek(0, SeekOrigin.Begin);
deserializer.Read(out d);
Assert.AreEqual(0.0, d);
deserializer.Read(out d);
Assert.AreEqual(Double.Epsilon, d);
deserializer.Read(out d);
Assert.AreEqual(Double.MinValue, d);
deserializer.Read(out d);
Assert.AreEqual(Double.MaxValue, d);
deserializer.Read(out d);
Assert.AreEqual(Double.NegativeInfinity, d);
deserializer.Read(out d);
Assert.AreEqual(Double.PositiveInfinity, d);
deserializer.Read(out d);
Assert.AreEqual(Double.NaN, d);
stream.Trim();
//stream.SetLength(0);
// Intermediate value tests
serializer.Write(0.001234);
serializer.Write(8765.4321);
stream.Rewind();
//stream.Seek(0, SeekOrigin.Begin);
deserializer.Read(out d);
Assert.AreEqual(0.001234, d);
deserializer.Read(out d);
Assert.AreEqual(8765.4321, d);
}
}
示例10: Deserialize
public override void Deserialize(Deserializer deserializer)
{
base.Deserialize(deserializer);
var touched = new Capo<bool>(fingerprint, tag.Offset);
if (touched[0])
{
deserializer.Read(out token_);
}
if (touched[1])
{
deserializer.Read(out retransmission_);
}
}