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


C# BinaryReader.ReadUtf8String方法代码示例

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


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

示例1: ReadFromFile

        public static void ReadFromFile(IndexPage indexPage, BinaryReader reader)
        {
            // Seek the stream to the first byte on page
            long initPos = reader.SetReadPos(Header.FILE_START_HEADER_SIZE + (indexPage.PageID * BasePage.PAGE_SIZE));

            if (reader.ReadByte() != (byte)PageType.Index)
                throw new FileDBException("PageID {0} is not a Index Page", indexPage.PageID);

            indexPage.NextPageID = reader.ReadUInt32();
            indexPage.SetUsedNodeCount(reader.ReadByte());
            // Seek the stream to end of header data page
            reader.SetReadPos(initPos + IndexPage.INDEX_HEADER_SIZE);

            //in this version 
            //each node uses buffer= 16+1+1+4+1+4+4+8+4+2+36 =81 
            //IndexPage.NODES_PER_PAGE = 50;
            //so it use 81*50 = 4050
            //IndexPage.INDEX_HEADER_SIZE =46
            //so => 4050 +46 = 4096 
            //and each page has BasePage.PAGE_SIZE = 4096 => matched

            for (int i = 0; i <= indexPage.UsedNodeCount; i++)
            {
                var node = indexPage.Nodes[i];

                node.ID = reader.ReadGuid(); //16

                node.IsDeleted = reader.ReadBoolean(); //1 

                node.Right.Index = reader.ReadByte(); //1 
                node.Right.PageID = reader.ReadUInt32(); //4
                node.Left.Index = reader.ReadByte(); //1 
                node.Left.PageID = reader.ReadUInt32();//4

                node.DataPageID = reader.ReadUInt32();//4

                node.FileMetaDataLength = reader.ReadUInt16();//2
                node.FileLength = reader.ReadUInt32();//4

                int filenameCount = reader.ReadByte(); //1
                if (filenameCount > IndexNode.FILENAME_SIZE)
                {
                    node.FileUrl = reader.ReadUtf8String(IndexNode.FILENAME_SIZE);
                }
                else
                {
                    string filename = reader.ReadUtf8String(IndexNode.FILENAME_SIZE);
                    node.FileUrl = filename.Substring(0, filenameCount);
                }
            }
        }
开发者ID:prepare,项目名称:FileDB,代码行数:51,代码来源:PageFactory.cs

示例2: Deserialize

		/// <summary>
		/// Deserializes a new instance of the ServerMessage1 class from the
		/// specified buffer of bytes.
		/// </summary>
		/// <param name="buffer">The byte buffer to deserialize the ServerMessage1
		/// instance from.</param>
		/// <returns>An instance of the ServerMessage1 class deserialized from the
		/// specified byte array.</returns>
		/// <exception cref="FormatException">Thrown if the byte buffer does not
		/// contain valid data.</exception>
		public static ServerMessage1 Deserialize(byte[] buffer) {
			using (var ms = new MemoryStream(buffer)) {
				using (var r = new BinaryReader(ms)) {
					uint bufferLength = r.ReadUInt32(true);
					// We don't support re-using previous sessions.
					byte reuse = r.ReadByte();
					if (reuse != 0) {
						throw new FormatException("Unexpected re-use parameter value: " +
							reuse);
					}
					Mpi N = r.ReadMpi();
					Mpi g = r.ReadMpi();
					OctetSequence salt = r.ReadOs();
					Mpi B = r.ReadMpi();
					Utf8String L = r.ReadUtf8String();
					return new ServerMessage1() {
						Generator = g,
						PublicKey = B,
						Salt = salt.Value,
						SafePrimeModulus = N,
						Options = ParseOptions(L.Value),
						RawOptions = L.Value
					};
				}
			}
		}
开发者ID:abhibecb,项目名称:S22.Imap,代码行数:36,代码来源:ServerMessage1.cs

示例3: Deserialize

        public static ServerMessage1 Deserialize(byte[] buffer)
        {
            using (var ms = new MemoryStream(buffer))
            {
                using (var r = new BinaryReader(ms))
                {
                    byte reuse = r.ReadByte();
                    if (reuse != 0)
                    {
                        throw new FormatException("Unexpected re-use parameter value: " + reuse);
                    }

                    Mpi n = r.ReadMpi();
                    Mpi g = r.ReadMpi();
                    OctetSequence salt = r.ReadOs();
                    Mpi b = r.ReadMpi();
                    Utf8String l = r.ReadUtf8String();
                    return new ServerMessage1()
                    {
                        Generator = g,
                        PublicKey = b,
                        Salt = salt.Value,
                        SafePrimeModulus = n,
                        Options = ParseOptions(l.Value),
                        RawOptions = l.Value
                    };
                }
            }
        }
开发者ID:BoyarinO,项目名称:EmailClient,代码行数:29,代码来源:ServerMessage1.cs

示例4: Deserialize

		/// <summary>
		/// Deserializes a new instance of the ServerMessage2 class from the
		/// specified buffer of bytes.
		/// </summary>
		/// <param name="buffer">The byte buffer to deserialize the ServerMessage2
		/// instance from.</param>
		/// <returns>An instance of the ServerMessage2 class deserialized from the
		/// specified byte array.</returns>
		/// <exception cref="FormatException">Thrown if the byte buffer does not
		/// contain valid data.</exception>
		public static ServerMessage2 Deserialize(byte[] buffer) {
			using (var ms = new MemoryStream(buffer)) {
				using (var r = new BinaryReader(ms)) {
					uint bufferLength = r.ReadUInt32(true);
					OctetSequence M2 = r.ReadOs(),
						sIV = r.ReadOs();
					Utf8String sid = r.ReadUtf8String();
					uint ttl = r.ReadUInt32(true);
					return new ServerMessage2() {
						Proof = M2.Value,
						InitialVector = sIV.Value,
						SessionId = sid.Value,
						Ttl = ttl
					};
				}
			}
		}
开发者ID:abhibecb,项目名称:S22.Imap,代码行数:27,代码来源:ServerMessage2.cs

示例5: ReadFromFile

        public static void ReadFromFile(Header header, BinaryReader reader)
        {
            // Seek the stream on 0 position to read header
            reader.BaseStream.Seek(0, SeekOrigin.Begin);

            // Make same validation on header file
            if (reader.ReadUtf8String(Header.FileID.Length) != Header.FileID)
                throw new FileDBException("The file is not a valid storage archive");

            if (reader.ReadInt16() != Header.FileVersion)
                throw new FileDBException("The archive version is not valid");

            header.IndexRootPageID = reader.ReadUInt32();
            header.FreeIndexPageID = reader.ReadUInt32();
            header.FreeDataPageID = reader.ReadUInt32();
            header.LastFreeDataPageID = reader.ReadUInt32();
            header.LastPageID = reader.ReadUInt32();
            header.IsDirty = false;
        }
开发者ID:prepare,项目名称:FileDB,代码行数:19,代码来源:HeaderFactory.cs

示例6: Deserialize

 ///<exclude/>
 public void Deserialize(BinaryReader br)
 {
     seq = br.ReadUInt32();
     stamp = br.ReadDateTime();
     frame_id = br.ReadUtf8String();
 }
开发者ID:terakenxx,项目名称:TukubaChallenge,代码行数:7,代码来源:Header.cs

示例7: Deserialize

 ///<exclude/>
 public void Deserialize(BinaryReader br)
 {
     header = new Header(br);
     ns = br.ReadUtf8String();
     id = br.ReadInt32();
     type = br.ReadInt32();
     action = br.ReadInt32();
     pose = new Pose(br);
     scale = new Vector3(br);
     color = new ColorRGBA(br);
     lifetime = br.ReadTimeSpan();
     frame_locked = br.ReadBoolean();
     points = new List<Point>(br.ReadInt32()); for(int i=0; i<points.Capacity; i++) { var x = new Point(br);points.Add(x);}
     colors = new List<ColorRGBA>(br.ReadInt32()); for(int i=0; i<colors.Capacity; i++) { var x = new ColorRGBA(br);colors.Add(x);}
     text = br.ReadUtf8String();
     mesh_resource = br.ReadUtf8String();
     mesh_use_embedded_materials = br.ReadBoolean();
 }
开发者ID:terakenxx,项目名称:TukubaChallenge,代码行数:19,代码来源:Marker.cs

示例8: Deserialize

 ///<exclude/>
 public void Deserialize(BinaryReader br)
 {
     header = new Header(br);
     child_frame_id = br.ReadUtf8String();
     transform = new Transform(br);
 }
开发者ID:terakenxx,项目名称:TukubaChallenge,代码行数:7,代码来源:TransformStamped.cs

示例9: Deserialize

 ///<exclude/>
 public void Deserialize(BinaryReader br)
 {
     header = new Header(br);
     level = br.ReadByte();
     name = br.ReadUtf8String();
     msg = br.ReadUtf8String();
     file = br.ReadUtf8String();
     function = br.ReadUtf8String();
     line = br.ReadUInt32();
     topics = new List<string>(br.ReadInt32()); for(int i=0; i<topics.Capacity; i++) { var x = br.ReadUtf8String();topics.Add(x);}
 }
开发者ID:garaemon,项目名称:RosSharp,代码行数:12,代码来源:Log.cs

示例10: Deserialize

 ///<exclude/>
 public void Deserialize(BinaryReader br)
 {
     label = br.ReadUtf8String();
     size = br.ReadUInt32();
     stride = br.ReadUInt32();
 }
开发者ID:garaemon,项目名称:RosSharp,代码行数:7,代码来源:MultiArrayDimension.cs

示例11: Deserialize

 ///<exclude/>
 public void Deserialize(BinaryReader br)
 {
     data = br.ReadUtf8String();
 }
开发者ID:garaemon,项目名称:RosSharp,代码行数:5,代码来源:String.cs

示例12: Deserialize

 ///<exclude/>
 public void Deserialize(BinaryReader br)
 {
     name = br.ReadUtf8String();
     level = br.ReadUtf8String();
 }
开发者ID:garaemon,项目名称:RosSharp,代码行数:6,代码来源:Logger.cs


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