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


C# CompactBinaryReader.ReadInt32方法代码示例

本文整理汇总了C#中CompactBinaryReader.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# CompactBinaryReader.ReadInt32方法的具体用法?C# CompactBinaryReader.ReadInt32怎么用?C# CompactBinaryReader.ReadInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CompactBinaryReader的用法示例。


在下文中一共展示了CompactBinaryReader.ReadInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例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: 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

示例4: 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

示例5: Instantiate

        public override object Instantiate(CompactBinaryReader reader)
        {
            int length = reader.ReadInt32();
            string typeName = reader.ReadString();
            Type t = Type.GetType(typeName);

            object graph = Array.CreateInstance(t, length);

            return graph;
        }
开发者ID:javithalion,项目名称:NCache,代码行数:10,代码来源:CustomArraySerializationSurrogate.cs

示例6: SkipDirect

 public override void SkipDirect(CompactBinaryReader reader, object graph)
 {
     int length = reader.ReadInt32();
     IDictionary dict = (IDictionary)graph;
     for (int i = 0; i < length; i++)
     {
         reader.SkipObject();
         reader.SkipObject();
     }
 }
开发者ID:javithalion,项目名称:NCache,代码行数:10,代码来源:IDictionarySerializationSurrogate.cs

示例7: Skip

 public override void Skip(CompactBinaryReader reader)
 {
     int cookie = reader.ReadInt32();
     object custom = reader.Context.GetObject(cookie);
     if (custom == null)
     {
         custom = SessionStateItemCollection.Deserialize(reader.BaseReader);
         reader.Context.RememberObject(custom,false);
     }
 }
开发者ID:javithalion,项目名称:NCache,代码行数:10,代码来源:SessionStateCollectionSerializationSurrogate.cs

示例8: Read

        public override sealed object Read(CompactBinaryReader reader)
        {
            int cookie = reader.ReadInt32();
            object graph = reader.Context.GetObject(cookie);
            if (graph == null)
            {
                bool bKnown = false;
                graph = Instantiate(reader);
                if (graph != null)
                {
                    reader.Context.RememberObject(graph,false);
                    bKnown = true;
                }

                if (VersionCompatible)
                {
                    long startPosition = 0;
                    int dataLength = 0;
                    long endPosition = 0;
                    startPosition = reader.BaseReader.BaseStream.Position;

                    dataLength = reader.ReadInt32();
                    graph = ReadDirect(reader, graph);

                    if (dataLength != -1 && (endPosition - startPosition) < dataLength)
                    {
                        endPosition = reader.BaseReader.BaseStream.Position;
                        reader.SkipBytes((int)(dataLength - (endPosition - startPosition)));
                    }
                }
                else
                {
                    graph = ReadDirect(reader, graph);
                }

                if (!bKnown)
                {
                    reader.Context.RememberObject(graph,false);
                }
            }
            return graph;
        }
开发者ID:javithalion,项目名称:NCache,代码行数:42,代码来源:ContextSensitiveSerializationSurrogate.cs

示例9: 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)
 {
     int cookie = reader.ReadInt32();
     object custom = reader.Context.GetObject(cookie);
     if (custom == null)
     {
         custom = HttpStaticObjectsCollection.Deserialize(reader.BaseReader);
         reader.Context.RememberObject(custom,false);
     }
     return custom;
 }
开发者ID:javithalion,项目名称:NCache,代码行数:17,代码来源:SessionStateStaticObjectCollectionSerializationSurrogate.cs

示例10: Skip

 public override void Skip(CompactBinaryReader reader)
 {
     int cookie = reader.ReadInt32();
     object custom = reader.Context.GetObject(cookie);
     if (custom == null)
     {
         BinaryFormatter formatter = new BinaryFormatter();
         custom = formatter.Deserialize(reader.BaseReader.BaseStream);
         reader.Context.RememberObject(custom,false);
     }
 }
开发者ID:javithalion,项目名称:NCache,代码行数:11,代码来源:ObjectSerializationSurrogate.cs

示例11: ReadDirect

 public override object ReadDirect(CompactBinaryReader reader, object graph)
 {
     int length = reader.ReadInt32();
     IDictionary dict = (IDictionary)graph;
     for (int i = 0; i < length; i++)
     {
         object key = reader.ReadObject();
         object value = reader.ReadObject();
         dict.Add(key, value);
     }
     return dict;
 }
开发者ID:javithalion,项目名称:NCache,代码行数:12,代码来源:IDictionarySerializationSurrogate.cs

示例12: 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)
        {
            int cookie = reader.ReadInt32();
            object custom = reader.Context.GetObject(cookie);
            if (custom == null)
            {
                //using new instance of binary fomatter instead of static which may cause exception when shared by multiple threads.
                BinaryFormatter formatter = new BinaryFormatter();
                custom = formatter.Deserialize(reader.BaseReader.BaseStream);
                reader.Context.RememberObject(custom, false);

            }
            return custom;
        }
开发者ID:javithalion,项目名称:NCache,代码行数:20,代码来源:ObjectSerializationSurrogate.cs

示例13: SkipDirect

 public override void SkipDirect(CompactBinaryReader reader, object graph)
 {
     String[] array = (String[])graph;
     for (int i = 0; i < array.Length; i++)
     {
         int length = reader.ReadInt16();
         if (length == 0)
         {
             array[i] = null;
             continue;
         }
         length = reader.ReadInt32();
         reader.ReadBytes(length);
     }
 }
开发者ID:christrotter,项目名称:NCache,代码行数:15,代码来源:StringArraySerializationSurrogate.cs

示例14: Instantiate

        public override object Instantiate(CompactBinaryReader reader)
        {
            int argumentsCount = reader.ReadInt32();
            Type[] arguments = new Type[argumentsCount];

            for (int i = 0; i < argumentsCount; i++)
            {
                string typeName = reader.ReadString();
                arguments[i] = Type.GetType(typeName);
            }

            object graph = SurrogateHelper.CreateGenericType("System.Collections.Generic.List", arguments);

            return graph;
        }
开发者ID:javithalion,项目名称:NCache,代码行数:15,代码来源:GenericIListSerializationSurrogate.cs

示例15: ReadDirect

        public override object ReadDirect(CompactBinaryReader reader, object graph)
        {
            String[] array = (String[])graph;
            for (int i = 0; i < array.Length; i++)
            {
                if (reader.ReadInt16() == 0)
                    continue;

                int length = reader.ReadInt32();
               
                byte[] stream = new byte[length];
                stream = reader.ReadBytes(length);
                array[i] =  UTF8Encoding.UTF8.GetString(stream);
            }
            return array;
        }
开发者ID:christrotter,项目名称:NCache,代码行数:16,代码来源:StringArraySerializationSurrogate.cs


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