当前位置: 首页>>代码示例>>C#>>正文


C# CompactBinaryReader类代码示例

本文整理汇总了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;
 }
开发者ID:javithalion,项目名称:NCache,代码行数:7,代码来源:DecimalArraySerializationSurrogate.cs

示例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();
 }
开发者ID:javithalion,项目名称:NCache,代码行数:7,代码来源:IListSerializationSurrogate.cs

示例3: Deserialize

 public override object Deserialize(Stream inputStream)
 {
     Initialize();
     var input = new InputStream(inputStream);
     var reader = new CompactBinaryReader<InputStream>(input);
     return _deserializerStream.Deserialize(reader);
 }
开发者ID:vasistbhargav,项目名称:GLD.SerializerBenchmark,代码行数:7,代码来源:BondCompactSerializer.cs

示例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));
        }
开发者ID:csdahlberg,项目名称:bond,代码行数:31,代码来源:program.cs

示例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);
 }
开发者ID:javithalion,项目名称:NCache,代码行数:7,代码来源:EnumSerializationSurrogate.cs

示例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;
 }
开发者ID:javithalion,项目名称:NCache,代码行数:7,代码来源:Int32ArraySerializationSurrogate.cs

示例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;
 }
开发者ID:javithalion,项目名称:NCache,代码行数:7,代码来源:ArraySerializationSurrogate.cs

示例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);
 }
开发者ID:huoxudong125,项目名称:serbench,代码行数:7,代码来源:BondSerializer.cs

示例9: SkipDirect

        public override void SkipDirect(CompactBinaryReader reader, object graph)
        {
            Array array = (Array)graph;

            for (int i = 0; i < array.Length; i++)
                reader.SkipObject();
        }
开发者ID:javithalion,项目名称:NCache,代码行数:7,代码来源:CustomArraySerializationSurrogate.cs

示例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();
 }
开发者ID:javithalion,项目名称:NCache,代码行数:8,代码来源:StringSerializationSurrogate.cs

示例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));
        }
开发者ID:javithalion,项目名称:NCache,代码行数:8,代码来源:EnumSerializationSurrogate.cs

示例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;
 }
开发者ID:javithalion,项目名称:NCache,代码行数:8,代码来源:IListSerializationSurrogate.cs

示例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();
 }
开发者ID:javithalion,项目名称:NCache,代码行数:8,代码来源:ObjectArraySerializationSurrogate.cs

示例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;
        }
开发者ID:javithalion,项目名称:NCache,代码行数:9,代码来源:AverageResultSerializationSurrogate.cs

示例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;
		}
开发者ID:edwardt,项目名称:MySpace-Data-Relay,代码行数:15,代码来源:BuiltinSurrogates.cs


注:本文中的CompactBinaryReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。