本文整理汇总了C#中CompactBinaryReader类的典型用法代码示例。如果您正苦于以下问题:C# CompactBinaryReader类的具体用法?C# CompactBinaryReader怎么用?C# CompactBinaryReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompactBinaryReader类属于命名空间,在下文中一共展示了CompactBinaryReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadDirect
public override object ReadDirect(CompactBinaryReader reader, object graph)
{
Decimal[] array = (Decimal[])graph;
for (int i = 0; i < array.Length; i++)
array[i] = (decimal)CompactBinaryFormatter.Deserialize(reader, reader.CacheContext, false);
return array;
}
示例2: SkipDirect
public override void SkipDirect(CompactBinaryReader reader, object graph)
{
int length = reader.ReadInt32();
IList list = (IList)graph;
for (int i = 0; i < length; i++)
reader.SkipObject();
}
示例3: Deserialize
public override object Deserialize(Stream inputStream)
{
Initialize();
var input = new InputStream(inputStream);
var reader = new CompactBinaryReader<InputStream>(input);
return _deserializerStream.Deserialize(reader);
}
示例4: Main
static void Main()
{
// The Example type internally uses instances generic schemas Generic1 and Generic2
var src = new Example
{
Field = { Field = new Generic2<int> { Field = 13 } }
};
// We can also instantiate generic schema in the C# program
var src1 = new Generic1<Example> { Field = src };
var src2 = new Generic2<double> {Field = 3.14};
var output = new OutputBuffer();
var writer = new CompactBinaryWriter<OutputBuffer>(output);
Serialize.To(writer, src);
Serialize.To(writer, src1);
Serialize.To(writer, src2);
var input = new InputBuffer(output.Data);
var reader = new CompactBinaryReader<InputBuffer>(input);
var dst = Deserialize<Example>.From(reader);
Debug.Assert(Comparer.Equal(src, dst));
var dst1 = Deserialize<Generic1<Example>>.From(reader);
Debug.Assert(Comparer.Equal(src1, dst1));
var dst2 = Deserialize<Generic2<double>>.From(reader);
Debug.Assert(Comparer.Equal(src2, dst2));
}
示例5: Skip
public override void Skip(CompactBinaryReader reader)
{
// Find an appropriate surrogate by handle
short handle = reader.ReadInt16();
ISerializationSurrogate typeSurr = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.Context.CacheContext);
typeSurr.Skip(reader);
}
示例6: ReadDirect
public override object ReadDirect(CompactBinaryReader reader, object graph)
{
Int32[] array = (Int32[])graph;
for (int i = 0; i < array.Length; i++)
array[i] = reader.ReadInt32();
return array;
}
示例7: ReadDirect
public override object ReadDirect(CompactBinaryReader reader, object graph)
{
Array array = (Array)graph;
for (int i = 0; i < array.Length; i++)
array.SetValue(reader.ReadObject(), i);
return array;
}
示例8: Deserialize
public override object Deserialize(Stream stream)
{
var input = new InputStream(stream);
var reader = new CompactBinaryReader<InputStream>(input);
return Bond.Deserialize<object>.From(reader);
//return _deserializer.Deserialize(reader);
}
示例9: SkipDirect
public override void SkipDirect(CompactBinaryReader reader, object graph)
{
Array array = (Array)graph;
for (int i = 0; i < array.Length; i++)
reader.SkipObject();
}
示例10: Read
public override object Read(CompactBinaryReader reader)
{
int length = reader.ReadInt32();
byte[] stream = new byte[length];
stream = reader.ReadBytes(length);
return UTF8Encoding.UTF8.GetString(stream);
//return reader.ReadString();
}
示例11: Read
public override object Read(CompactBinaryReader reader)
{
// Find an appropriate surrogate by handle
short handle = reader.ReadInt16();
ISerializationSurrogate typeSurr = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle,reader.Context.CacheContext);
return Enum.ToObject(ActualType, typeSurr.Read(reader));
}
示例12: ReadDirect
public override object ReadDirect(CompactBinaryReader reader, object graph)
{
int length = reader.ReadInt32();
IList list = (IList)graph;
for (int i = 0; i < length; i++)
list.Add(reader.ReadObject());
return list;
}
示例13: SkipDirect
public override void SkipDirect(CompactBinaryReader reader, object graph)
{
object[] array = (object[])graph;
short handle = reader.ReadInt16();
ISerializationSurrogate surrogate = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.CacheContext);
for (int i = 0; i < array.Length; i++)
reader.SkipObject();
}
示例14: Read
public override object Read(CompactBinaryReader reader)
{
ISerializationSurrogate decimalSurrogate = TypeSurrogateSelector.GetSurrogateForType(typeof(decimal), null);
AverageResult result = new AverageResult();
result.Sum = (decimal)decimalSurrogate.Read(reader);
result.Count = (decimal)decimalSurrogate.Read(reader);
return result;
}
示例15: Read
/// <summary>
/// Uses a <see cref="BinaryFormatter"/> to read an object of
/// type <see cref="ActualType"/> from the underlying stream.
/// </summary>
/// <param name="reader">stream reader</param>
/// <returns>object read from the stream reader</returns>
public override object Read(CompactBinaryReader reader)
{
object result = formatter.Deserialize(reader.BaseStream);
if (result != null)
{
Serializer.AlertLegacySerialization(result.GetType());
}
return result;
}