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


C# System.IO.BinaryReader.ReadInt32方法代码示例

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


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

示例1: DeserializeVoxelAreaData

		public static void DeserializeVoxelAreaData (byte[] bytes, VoxelArea target) {
			
			Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile();
			System.IO.MemoryStream stream = new System.IO.MemoryStream();
			stream.Write(bytes,0,bytes.Length);
			stream.Position = 0;
			zip = Ionic.Zip.ZipFile.Read(stream);
			System.IO.MemoryStream stream2 = new System.IO.MemoryStream();
			
			zip["data"].Extract (stream2);
			stream2.Position = 0;
			System.IO.BinaryReader reader = new System.IO.BinaryReader(stream2);
			
			int width = reader.ReadInt32();
			int depth = reader.ReadInt32();
			if (target.width != width) throw new System.ArgumentException ("target VoxelArea has a different width than the data ("+target.width + " != " + width + ")");
			if (target.depth != depth) throw new System.ArgumentException ("target VoxelArea has a different depth than the data ("+target.depth + " != " + depth + ")");
			LinkedVoxelSpan[] spans = new LinkedVoxelSpan[reader.ReadInt32()];
			
			for (int i=0;i<spans.Length;i++) {
				spans[i].area = reader.ReadInt32();
				spans[i].bottom = reader.ReadUInt32();
				spans[i].next = reader.ReadInt32();
				spans[i].top = reader.ReadUInt32();
			}
			target.linkedSpans = spans;
		}
开发者ID:henryj41043,项目名称:TheUnseen,代码行数:27,代码来源:VoxelClasses.cs

示例2: LoadData

        /// <summary>
        /// ファイルからデータをロード
        /// </summary>
        public static void LoadData()
        {
            if(System.IO.File.Exists(@SAVEFILE)){
                using(var fs = System.IO.File.Open(@SAVEFILE,System.IO.FileMode.Open)){
                    // バイナリリーダ作成
                    var br = new System.IO.BinaryReader(fs);

                    // Read data
                    Global.isStageOpened[(int)StageID.Stage1] = br.ReadBoolean();
                    Global.isStageOpened[(int)StageID.Stage2] = br.ReadBoolean();
                    Global.isStageOpened[(int)StageID.Stage3] = br.ReadBoolean();

                    Global.characterLevel = br.ReadInt32();
                    Global.characterExp = br.ReadInt32();

                    br.Close();
                }
            }else{
                Global.isStageOpened[(int)StageID.Stage1] = true;
                Global.isStageOpened[(int)StageID.Stage2] = false;
                Global.isStageOpened[(int)StageID.Stage3] = false;

                Global.characterLevel = 1;
                Global.characterExp = 0;
            }
        }
开发者ID:noradium,项目名称:Black-Rins-ambition,代码行数:29,代码来源:FileIO.cs

示例3: From3DMAXStream

        public static FullAnimation From3DMAXStream(System.IO.Stream stream, SkeletonExtended skeleton, bool reverse)
        {
            Matrix[][] Frames;
            var clip = new FullAnimation();
            var reader = new System.IO.BinaryReader(stream);
            var start = reader.ReadInt32();
            var end = reader.ReadInt32();
            var length = end - start + 1;
            clip.BonesCount = reader.ReadInt32();
            var counter = reader.ReadInt32();
            Frames = new Matrix[length][];
            for (int i = 0; i < length; i++)
                Frames[i] = new Matrix[clip.BonesCount];
            for (int i = 0; i < clip.BonesCount; i++)
                for (int j = 0; j < length; j++)
                    Frames[j][i] = reader.ReadMatrix();
            //теперь надо вычислить дельты
            //(идёт загрузка экспортированного из макса)
            for (int i = 0; i < clip.BonesCount; i++)
                for (int @in = 0; @in < length; @in++)
                    Frames[@in][i] = skeleton.baseskelet.bones[i].BaseMatrix * Frames[@in][i];

            if (reverse)
            {
                //Matrix[][] FramesTmp = new Matrix[length][];
                Frames = Frames.Reverse().ToArray();
            }
            Matrix[][] relatedMatrices = Animation.GetRelatedMatrices(Frames, skeleton.baseskelet);
            DecomposedMatrix[][] decomposedMatrices = GetDecomposedMatrices(skeleton.baseskelet, relatedMatrices);

            clip.matrices = decomposedMatrices;
            return clip;
        }
开发者ID:KatekovAnton,项目名称:Game,代码行数:33,代码来源:AnimationFull.cs

示例4: btnChooseFile_Click

        private void btnChooseFile_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".data";
            dlg.Filter = "Frame data (*.data)|*.data";

            // Display OpenFileDialog by calling ShowDialog method
            Nullable<bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                frameList.Clear();
                // Open document
                string filename = dlg.FileName;
                using (System.IO.BinaryReader br =
                    new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open)))
                {
                    while (br.BaseStream.Position < br.BaseStream.Length)
                    {
                        //deserialises and reads the binary file
                        DateTime date = new DateTime();
                        date = DateTime.FromBinary(br.ReadInt64());
                        // Console.WriteLine(date.ToString());

                        Int32 stimCode = br.ReadInt32();

                        Int32 nextBlock = br.ReadInt32();
                        byte[] frameData = br.ReadBytes(nextBlock);
                        Leap.Frame newFrame = new Leap.Frame();
                        newFrame.Deserialize(frameData);

                        if (stimCode == 5443)
                        {
                            Debug.WriteLine("5443 detected: " + newFrame.Id);
                        }
                        frameList.Add(newFrame);
                        //Console.WriteLine(newFrame.CurrentFramesPerSecond);

                    }
                    br.Close();
                    br.Dispose();
                }
                /* WRITE CODE HERE TO EXTRACT DATA FROM FILE
                foreach (Leap.Frame frame in frameList)
                {
                    //Console.WriteLine(frame.Id);
                }
                */

            }
        }
开发者ID:frizensami,项目名称:LeapMotionDataCapture,代码行数:55,代码来源:MainWindow.xaml.cs

示例5: Deserialize

 public static ChunkRangesRequest Deserialize(byte[] bytes)
 {
     Tuple<byte[],byte[]>[] ranges;
     using (System.IO.MemoryStream MS  = new System.IO.MemoryStream (bytes,false)) {
         using (System.IO.BinaryReader BR= new System.IO.BinaryReader(MS)) {
             ranges = new Tuple<byte[], byte[]>[BR.ReadInt32 ()];
             for (int n = 0; n != ranges.Length; n++) {
                 ranges [n] = new Tuple<byte[], byte[]> (BR.ReadBytes (BR.ReadInt32 ()), BR.ReadBytes (BR.ReadInt32 ()));
             }
         }
         return new ChunkRangesRequest (ranges);
     }
 }
开发者ID:vebin,项目名称:BD2,代码行数:13,代码来源:ChunkRangesRequest.cs

示例6: Read

		public static ZipFile Read ( System.IO.Stream stream ) {
			ZipFile file = new ZipFile();

			var reader = new System.IO.BinaryReader ( stream );
			int count = reader.ReadInt32 ();
			for ( int i = 0; i < count; i++ ) {
				var name = reader.ReadString();
				var length = reader.ReadInt32 ();
				var bytes = reader.ReadBytes (length);

				file.dict[name] = new ZipEntry(name, bytes);
			}

			return file;
		}
开发者ID:JtheSpaceC,项目名称:Breaking-The-Rules,代码行数:15,代码来源:SimpleZipReplacement.cs

示例7: Parse

        public void Parse(Header header, byte[] data)
        {
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(data))
            {
                using (System.IO.BinaryReader br = new System.IO.BinaryReader(ms))
                {
                    _authCode = br.ReadInt32();
                    _accountId = br.ReadUInt32();
                    _userLevel = br.ReadUInt32();
                    _lastLoginIP = br.ReadUInt32();
                    _lastLoginTime = br.ReadBytes(26);
                    _sex = br.ReadByte();

                    _serverList = new Dictionary<string, Server>();
                    for (int i = (int)ms.Position; i < header.Size; i += 32)
                    {
                        Server s = new Server();
                        s.IP = string.Format("{0}.{1}.{2}.{3}", br.ReadByte(), br.ReadByte(), br.ReadByte(), br.ReadByte());
                        s.Port = br.ReadInt16();
                        s.Name = br.ReadBytes(22).NullByteTerminatedString();
                        s.Type = br.ReadInt16();
                        s.UserCount = br.ReadInt16();
                        _serverList.Add(s.Name, s);
                    }
                }
            }
        }
开发者ID:scriptord3,项目名称:Mjolnir,代码行数:27,代码来源:Accept_Login.cs

示例8: GetDllMachineType

 public static MachineType GetDllMachineType(this string dllPath)
 {
     // See http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx
     // Offset to PE header is always at 0x3C.
     // The PE header starts with "PE\0\0" =  0x50 0x45 0x00 0x00,
     // followed by a 2-byte machine type field (see the document above for the enum).
     //
     using (var fs = new System.IO.FileStream(dllPath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
         using (var br = new System.IO.BinaryReader(fs)) {
             MachineType machineType = MachineType.IMAGE_FILE_MACHINE_UNKNOWN;
     //					bool isgood = false;
             try {
                 fs.Seek(0x3c, System.IO.SeekOrigin.Begin);
                 Int32 peOffset = br.ReadInt32();
                 fs.Seek(peOffset, System.IO.SeekOrigin.Begin);
                 UInt32 peHead = br.ReadUInt32();
                 if (peHead != 0x00004550)
                     // "PE\0\0", little-endian
                     throw new Exception("Can't find PE header");
                 machineType = (MachineType)br.ReadUInt16();
     //						isgood = true;
             }
             catch {
     //						isgood = false;
             }
             finally {
                 br.Close();
                 fs.Close();
             }
             return machineType;
         }
 }
开发者ID:tfwio,项目名称:modest-smf-vstnet,代码行数:32,代码来源:DllExtension.cs

示例9: Load

        public static void Load()
        {
            IO.Log.Write("    Loading CampaingProgresss...");
            levelsCompleted.Clear();

            System.IO.BinaryReader br = new System.IO.BinaryReader(new System.IO.FileStream("Saves/progress.lpg",
                System.IO.FileMode.Open));

            String s = "";
            int l = 0;
            while (br.PeekChar() > -1)
            {
                s = br.ReadString();
                l = br.ReadInt32();
                byte[] d = new byte[l];
                for (int j = 0; j < l; j++)
                {
                    d[j] = br.ReadByte();
                }
                levelsCompleted.Add(s, d);
            }

            br.Close();
            IO.Log.Write("    Loading complete");
        }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:25,代码来源:CampaingProgress.cs

示例10: Load

        public void Load(string filename)
        {
            System.IO.BinaryReader br = new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open));

            width = br.ReadInt32();
            height = br.ReadInt32();

            Create(width, height);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int attrCnt = 0;

                    groundData[x, y].type = br.ReadInt32();
                    attrCnt = br.ReadInt32();
                    for (int k = 0; k < attrCnt; k++)
                    {
                        int attr;
                        attr = br.ReadInt32();
                        groundData[x, y].attributes.Add(attr);
                    }
                }
            }

            int entityCnt = 0;
            entityCnt = br.ReadInt32();
            for (int e = 0; e < entityCnt; e++)
            {
                Cell entityCell = new Cell();
                int x, y, attrCnt;
                entityCell.type = br.ReadInt32();
                entityCell.empty = false;
                x = br.ReadInt32();
                y = br.ReadInt32();

                attrCnt = br.ReadInt32();
                for (int k = 0; k < attrCnt; k++)
                {
                    entityCell.attributes.Add(br.ReadInt32());
                }

                entityData[x, y] = entityCell;
            }
            br.Close();
        }
开发者ID:Hibchibbler,项目名称:TankGame,代码行数:47,代码来源:Map.cs

示例11: LoadBody

 public void LoadBody(byte[] buffer)
 {
     System.IO.BinaryReader br = new System.IO.BinaryReader(new System.IO.MemoryStream(buffer));
     int count = br.ReadInt32();
     lodMats = new Lod[count];
     for (int i = 0; i < count; i++)
     {
         lodMats[i] = new Lod();
         int matc = br.ReadInt32();
         lodMats[i].mats = new SubsetMaterial[matc];
         for (int j = 0; j < matc; j++)
         {
             lodMats[i].mats[j] = new SubsetMaterial();
             lodMats[i].mats[j].DiffuseTextureName = br.ReadPackString();
         }
     }
 }
开发者ID:KatekovAnton,项目名称:Game,代码行数:17,代码来源:MaterialDescription.cs

示例12: UsingTest

 public void UsingTest()
 {
     using (var s = System.IO.File.Open(GetTestDataFilePath("SPATIAL_F_SKARVMUFF.shp"), System.IO.FileMode.Open))
     {
         using (var reader = new System.IO.BinaryReader(s))
         {
             System.Console.WriteLine(reader.ReadInt32());
         }
         NUnit.Framework.Assert.Throws<System.ObjectDisposedException>(() => System.Console.WriteLine(s.Position));
     } 
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:11,代码来源:ShapeFileProviderTests.cs

示例13: DeserializeArray

 public object[] DeserializeArray(byte[] buffer)
 {
     System.IO.MemoryStream MS = new System.IO.MemoryStream (buffer);
     System.IO.BinaryReader BR = new System.IO.BinaryReader (MS);
     object[] objects = new object[BR.ReadInt32 ()];
     int n = 0;
     while (MS.Position < MS.Length) {
         objects [n] = Deserialize (BR);
         n++;
     }
     return objects;
 }
开发者ID:vebin,项目名称:BD2,代码行数:12,代码来源:ValueSerializerBase.cs

示例14: RGSSTable

 public RGSSTable(byte[] raw)
 {
     System.IO.MemoryStream s = new System.IO.MemoryStream(raw);
     System.IO.BinaryReader r = new System.IO.BinaryReader(s);
     this.dimensions = (byte)r.ReadInt32();
     int x = r.ReadInt32();
     int y = r.ReadInt32();
     int z = r.ReadInt32();
     long check = r.ReadInt32();
     this.value = new short[x, y, z];
     for (int j = 0; j < z; j++)
     {
         for (int k = 0; k < y; k++)
         {
             for (int l = 0; l < x; l++)
             {
                 this[l, k, j] = r.ReadInt16();
             }
         }
     }
 }
开发者ID:NekoProject,项目名称:NekoKun,代码行数:21,代码来源:RGSSTable.cs

示例15: CheckWin32Header

 /// <summary>Checks whether a specified file is a valid Win32 plugin.</summary>
 /// <param name="file">The file to check.</param>
 /// <returns>Whether the file is a valid Win32 plugin.</returns>
 private static bool CheckWin32Header(string file)
 {
     using (System.IO.FileStream stream = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read)) {
         using (System.IO.BinaryReader reader = new System.IO.BinaryReader(stream)) {
             if (reader.ReadUInt16() != 0x5A4D) {
                 /* Not MZ signature */
                 return false;
             }
             stream.Position = 0x3C;
             stream.Position = reader.ReadInt32();
             if (reader.ReadUInt32() != 0x00004550) {
                 /* Not PE signature */
                 return false;
             }
             if (reader.ReadUInt16() != 0x014C) {
                 /* Not IMAGE_FILE_MACHINE_I386 */
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:sladen,项目名称:openbve,代码行数:25,代码来源:PluginManager.cs


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