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


C# BigEndianBinaryReader.ReadBytes方法代码示例

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


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

示例1: ReadBundleFiles

        private IEnumerable<HgBundleFile> ReadBundleFiles(BigEndianBinaryReader binaryReader)
        {
            uint fileNameLength;
            while((fileNameLength = binaryReader.ReadUInt32()) != 0)
            {
                var fileNameBytes = binaryReader.ReadBytes((int)fileNameLength - 4 /* For "file name length" value itself */);
                var fileName = hgEncoder.DecodeAsLocal(fileNameBytes);
                var fileGroup = ReadBundleGroup(binaryReader);

                var file = new HgBundleFile(new HgPath(fileName), fileGroup);
                yield return file;
            } // while
        }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:13,代码来源:HgBundleReader.cs

示例2: Main

        static void Main( string[] args )
        {
            if (args.Length != 1) {
                PrintHelp();
                return;
            }

            BigEndianBinaryReader bebr = null;
            try {
                bebr = new BigEndianBinaryReader( new FileStream(args[0], FileMode.Open) );
            } catch (Exception ex) {
                Console.WriteLine("Error : {0}", ex.Message);
                return;
            }
            Header header = bebr.ReadBytes(Marshal.SizeOf(typeof(Header))).ToStruct<Header>();

            if (header.magic != 0x01000000004DA2DC) {
                Console.WriteLine("Not a valid TRP file.");
                return;
            }
            FileOffsetInfo[] fileOffsetInfoArray = new FileOffsetInfo[header.AllFileCount];
            for (int i = 0; i < header.AllFileCount; i++) {
                fileOffsetInfoArray[i] = bebr.ReadBytes(Marshal.SizeOf(typeof(FileOffsetInfo))).ToStruct<FileOffsetInfo>();
            }

            foreach (FileOffsetInfo foi in fileOffsetInfoArray) {
                bebr.BaseStream.Position = foi.Offset;
                FileStream fs = new FileStream(foi.fileName, FileMode.Create);
                byte [] towritefiledata = bebr.ReadBytes( (int) foi.FileSize );
                fs.Write(towritefiledata, 0, towritefiledata.Length);
                fs.Flush();
                fs.Close();
                Console.WriteLine(foi.fileName);
            }

            Console.WriteLine("Extract finished");
            bebr.Close();
            return;
        }
开发者ID:darkautism,项目名称:PS3TRPExtractor,代码行数:39,代码来源:Program.cs

示例3: ShapefileEnumerator

            /// <summary>
            /// Initializes a new instance of the ShapefileEnumerator class.
            /// </summary>
            /// <param name="shapefile"></param>
            public ShapefileEnumerator(ShapeReader shapefile)
            {                
                _parent = shapefile;

                // create a file stream for each enumerator that is given out. This allows the same file
                // to have one or more enumerator. If we used the parents stream - than only one IEnumerator 
                // could be given out.
                FileStream stream = new FileStream(_parent._filename, System.IO.FileMode.Open, FileAccess.Read, FileShare.Read);
                _shpBinaryReader = new BigEndianBinaryReader(stream);

                // skip header - since parent has already read this.
                _shpBinaryReader.ReadBytes(100);
                ShapeGeometryTypes type = _parent._mainHeader.ShapeType;
                _handler = Shapefile.GetShapeHandler(type);
                if (_handler == null) 
                    throw new NotSupportedException("Unsuported shape type:" + type);
            }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:21,代码来源:ShapeReader.cs

示例4: TROPUSR

        public TROPUSR(string path_in)
        {
            this.path = path_in;
            BigEndianBinaryReader TROPUSRReader = null;

            if (path == null)
                throw new Exception("Path cannot be null!");

            if (!path.EndsWith(@"\"))
                path += @"\";

            if (!File.Exists(path + "TROPUSR.DAT"))
                throw new Exception("Cannot find TROPUSR.DAT.");

            try {
                TROPUSRReader = new BigEndianBinaryReader(new FileStream(path + "TROPUSR.DAT", FileMode.Open));
            } catch (IOException) {
                throw new Exception("Cannot Open TROPUSR.DAT.");
            }

            header = TROPUSRReader.ReadBytes(Marshal.SizeOf(typeof(Header))).ToStruct<Header>();
            if (header.Magic != 0x0000000100ad548f81)
                throw new Exception("Not a vaild TROPUSR.DAT.");

            typeRecordTable = new Dictionary<int, TypeRecord>();
            for (int i = 0; i < header.UnknowCount; i++) {
                TypeRecord TypeRecordTmp = TROPUSRReader.ReadBytes(Marshal.SizeOf(typeof(TypeRecord))).ToStruct<TypeRecord>();
                typeRecordTable.Add(TypeRecordTmp.ID, TypeRecordTmp);
            }

            do {
                // 1 unknow 2 account_id 3 trophy_id and hash(?) 4 trophy info
                //
                int type = TROPUSRReader.ReadInt32();
                int blocksize = TROPUSRReader.ReadInt32();
                int sequenceNumber = TROPUSRReader.ReadInt32(); // if have more than same type block, it will be used
                int unknow = TROPUSRReader.ReadInt32();
                byte[] blockdata = TROPUSRReader.ReadBytes(blocksize);
                switch (type) {
                    case 1: // unknow
                        break;
                    case 2:
                        account_id = Encoding.UTF8.GetString(blockdata, 16, 16);
                        break;
                    case 3:
                        trophy_id = Encoding.UTF8.GetString(blockdata, 0, 16).Trim('\0');
                        short u1 = BitConverter.ToInt16(blockdata, 16).ChangeEndian();
                        short u2 = BitConverter.ToInt16(blockdata, 18).ChangeEndian();
                        short u3 = BitConverter.ToInt16(blockdata, 20).ChangeEndian();
                        short u4 = BitConverter.ToInt16(blockdata, 22).ChangeEndian();
                        all_trophy_number = BitConverter.ToInt32(blockdata, 24).ChangeEndian();
                        int u5 = BitConverter.ToInt32(blockdata, 28).ChangeEndian();
                        AchievementRate[0] = BitConverter.ToUInt32(blockdata, 64);
                        AchievementRate[1] = BitConverter.ToUInt32(blockdata, 68);
                        AchievementRate[2] = BitConverter.ToUInt32(blockdata, 72);
                        AchievementRate[3] = BitConverter.ToUInt32(blockdata, 76);
                        break;
                    case 4:
                        trophyTypeTable.Add(blockdata.ToStruct<TrophyType>());
                        break;
                    case 5:
                        trophyListInfo = blockdata.ToStruct<TrophyListInfo>();
                        break;
                    case 6:
                        trophyTimeInfoTable.Add(blockdata.ToStruct<TrophyTimeInfo>());
                        break;
                    case 7:// unknow
                        unknowType7 = blockdata.ToStruct<UnknowType7>();
                        // Console.WriteLine("Unsupported block type. (Type{0})", type);
                        break;
                    case 8: // hash
                        unknowHash = blockdata.SubArray(0, 20);
                        break;
                    case 9: // 通常寫著白金獎盃的一些數字,不明
                        // Console.WriteLine("Unsupported block type. (Type{0})", type);
                        break;
                    case 10: // i think it just a padding
                        break;
                }

            } while (TROPUSRReader.BaseStream.Position < TROPUSRReader.BaseStream.Length);

            trophyListInfo.ListLastUpdateTime = DateTime.Now;
            TROPUSRReader.Close();
        }
开发者ID:darkautism,项目名称:TROPHYParser,代码行数:85,代码来源:TROPUSR.cs

示例5: GetZMValues

        /// <summary>
        /// Get the z values and populate each one of them in Coordinate.Z
        /// If there are M values, return an array with those.
        /// </summary>
        /// <param name="file">The reader</param>
        /// <param name="totalRecordLength">Total number of bytes in this record</param>
        /// <param name="currentlyReadBytes">How many bytes are read from this record</param>
        /// <param name="buffer">The coordinate buffer</param>
        /// <param name="skippedList">A list of indices which have not been added to the buffer</param>     
        protected void GetZMValues(BigEndianBinaryReader file, int totalRecordLength, ref int currentlyReadBytes, ICoordinateBuffer buffer, HS skippedList = null)
        {
            if (skippedList == null)
                skippedList = new HS();

            var numPoints = buffer.Capacity;

            if (HasZValue())
            {
                boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes);
                boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes);

                var numSkipped = 0;
                for (var i = 0; i < numPoints; i++)
                {
                    var z = ReadDouble(file, totalRecordLength, ref currentlyReadBytes);
                    if (!skippedList.Contains(i))
                        buffer.SetZ(i-numSkipped, z);
                    else numSkipped++;
                }
            }

            // Trond: Note that M value is always optional per the shapefile spec. So we need to test total read record bytes
            // v.s. read bytes to see if we have them or not
            // Also: If we have Z we might have M. Per shapefile defn.
            if ((HasMValue() || HasZValue()) && currentlyReadBytes < totalRecordLength)
            {
                boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes);
                boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes);

                var numSkipped = 0;
                for (var i = 0; i < numPoints; i++)
                {
                    var m = ReadDouble(file, totalRecordLength, ref currentlyReadBytes);
                    if (!skippedList.Contains(i))
                        buffer.SetM(i - numSkipped, m);
                    else numSkipped++;
                }
            }

            if (currentlyReadBytes < totalRecordLength)
            {
                int remaining = totalRecordLength - currentlyReadBytes;
                file.ReadBytes(remaining * 2);
            }
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:55,代码来源:ShapeHandler.cs

示例6: ReadAttributes

 AttributeInfo[] ReadAttributes(BigEndianBinaryReader reader)
 {
     /*
         u2 attributes_count;
         attribute_info attributes[attributes_count];
     */
     ushort attributesCount = reader.ReadUInt16();
     AttributeInfo[] attributes = new AttributeInfo[attributesCount];
     if (attributesCount == 0) {
         return attributes;
     }
     for (ushort i = 0; i < attributesCount; i++) {
         /*
             attribute_info {
                 u2 attribute_name_index;
                 u4 attribute_length;
                 u1 info[attribute_length];
             }
         */
         AttributeInfo attr;
         attr.AttributeNameIndex = reader.ReadUInt16();
         attr.Bytes = reader.ReadBytes(reader.ReadUInt32());
         attributes[i] = attr;
     }
     return attributes;
 }
开发者ID:olympum,项目名称:caffeine,代码行数:26,代码来源:ClassFile.cs

示例7: TROPTRNS

        public TROPTRNS(string path_in)
        {
            this.path = path_in;
            BigEndianBinaryReader TROPTRNSReader = null;
            try {

                if (path == null)
                    throw new Exception("Path cannot be null!");

                if (!path.EndsWith(@"\"))
                    path += @"\";

                if (!File.Exists(path + "TROPTRNS.DAT"))
                    throw new Exception("Cannot find TROPTRNS.DAT.");

                try {
                    TROPTRNSReader = new BigEndianBinaryReader(new FileStream(path + "TROPTRNS.DAT", FileMode.Open));
                } catch (IOException) {
                    throw new Exception("Cannot Open TROPTRNS.DAT.");
                }

                header = TROPTRNSReader.ReadBytes(Marshal.SizeOf(typeof(Header))).ToStruct<Header>();
                if (header.Magic != 0x0000000100ad548f81) {
                    TROPTRNSReader.Close();
                    throw new Exception("Not a vaild TROPTRNS.DAT.");
                }

                typeRecordTable = new Dictionary<int, TypeRecord>();
                for (int i = 0; i < header.UnknowCount; i++) {
                    TypeRecord TypeRecordTmp = TROPTRNSReader.ReadBytes(Marshal.SizeOf(typeof(TypeRecord))).ToStruct<TypeRecord>();
                    typeRecordTable.Add(TypeRecordTmp.ID, TypeRecordTmp);
                }

                // Type 2
                TypeRecord account_id_Record = typeRecordTable[2];
                TROPTRNSReader.BaseStream.Position = account_id_Record.Offset + 32; // 空行
                account_id = Encoding.UTF8.GetString(TROPTRNSReader.ReadBytes(16));

                // Type 3
                TypeRecord trophy_id_Record = typeRecordTable[3];
                TROPTRNSReader.BaseStream.Position = trophy_id_Record.Offset + 16; // 空行
                trophy_id = Encoding.UTF8.GetString(TROPTRNSReader.ReadBytes(16)).Trim('\0');
                u1 = TROPTRNSReader.ReadInt32(); // always 00000090
                AllGetTrophysCount = TROPTRNSReader.ReadInt32();
                AllSyncPSNTrophyCount = TROPTRNSReader.ReadInt32();

                // Type 4
                TypeRecord TrophyInfoRecord = typeRecordTable[4];
                TROPTRNSReader.BaseStream.Position = TrophyInfoRecord.Offset; // 空行
                int type = TROPTRNSReader.ReadInt32();
                int blocksize = TROPTRNSReader.ReadInt32();
                int sequenceNumber = TROPTRNSReader.ReadInt32(); // if have more than same type block, it will be used
                int unknow = TROPTRNSReader.ReadInt32();
                byte[] blockdata = TROPTRNSReader.ReadBytes(blocksize);
                trophyInitTime = blockdata.ToStruct<TrophyInitTime>();

                for (int i = 0; i < (AllGetTrophysCount - 1); i++) {
                    TROPTRNSReader.BaseStream.Position += 16;
                    TrophyInfo ti = TROPTRNSReader.ReadBytes(blocksize).ToStruct<TrophyInfo>();
                    trophyInfoTable.Add(ti);
                }
            } finally {
                if (TROPTRNSReader != null) TROPTRNSReader.Close();
            }
        }
开发者ID:darkautism,项目名称:TROPHYParser,代码行数:65,代码来源:TROPTRNS.cs


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