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


C# Stream.ReadValueU32方法代码示例

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


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

示例1: Load

        public static WwiseIndex Load(Stream input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            var magic = input.ReadValueU32(Endian.Little);
            if (magic != 0x58444957 &&
                magic.Swap() != 0x58444957)
            {
                throw new FormatException("invalid magic");
            }
            var endian = magic == 0x58444957 ? Endian.Little : Endian.Big;

            var version = input.ReadValueU32(endian);
            if (version != 1)
            {
                throw new FormatException("unexpected version");
            }

            var reader = new FileFormats.Unreal.FileReader(input, version, endian);

            var index = new WwiseIndex();
            index.Serialize(reader);
            return index;
        }
开发者ID:rjbarroso,项目名称:Gibbed.MassEffect3,代码行数:27,代码来源:WwiseIndex.cs

示例2: Deserialize

        public void Deserialize(Stream input)
        {
            var magic = input.ReadValueU32(Endian.Little);
            if (magic != 0x434F4E44 && // COND
                magic.Swap() != 0x434F4E44)
            {
                throw new FormatException();
            }
            var endian = magic == 0x434F4E44 ? Endian.Little : Endian.Big;

            var version = input.ReadValueU32(endian);
            if (version != 1)
            {
                throw new FormatException();
            }
            this.Version = version;

            var unknown08 = input.ReadValueU16(endian);
            var count = input.ReadValueU16(endian);

            var ids = new int[count];
            var offsets = new uint[count];
            for (ushort i = 0; i < count; i++)
            {
                ids[i] = input.ReadValueS32(endian);
                offsets[i] = input.ReadValueU32(endian);
            }

            for (ushort i = 0; i < count; i++)
            {
                var id = ids[i];
                var offset = offsets[i];

                input.Seek(offset, SeekOrigin.Begin);

                var flags = input.ReadValueU8();

                var valueType = (Conditionals.ValueType)((flags & 0x0F) >> 0);
                var opType = (Conditionals.OpType)((flags & 0xF0) >> 4);

                if (valueType == Conditionals.ValueType.Bool)
                {
                    switch (opType)
                    {
                        default:
                        {
                            throw new NotSupportedException();
                        }
                    }
                }
            }

            //throw new NotImplementedException();

            this.Endian = endian;
        }
开发者ID:CreeperLava,项目名称:ME3Explorer,代码行数:56,代码来源:ConditionalsFile.cs

示例3: Deserialize

        public void Deserialize(Stream input)
        {
            var magic = input.ReadValueU32(this.LittleEndian);

            if (magic != 0x54414653)
                throw new NotSupportedException("Bad magic number");

            this.Unknown04 = input.ReadValueU32(this.LittleEndian);
            this.NumberOfFiles = input.ReadValueU32(this.LittleEndian);

            var count = input.ReadValueU32(this.LittleEndian);

            this.Unknown10 = input.ReadValueU32(this.LittleEndian);

            this.BasePath = input.ReadString(32, true, Encoding.ASCII);

            this.Entries.Clear();
            for (uint i = 0; i < count; i++)
            {
                var entry = new Big.EntryV2();
                entry.NameHash = input.ReadValueU32(this.LittleEndian);
                entry.Locale = input.ReadValueU32(this.LittleEndian);
                entry.Size = input.ReadValueU32(this.LittleEndian);
                var offset = input.ReadValueU32(this.LittleEndian);
                entry.Offset = offset & 0xFFFFFF00;
                entry.File = offset & 0xFF;
                this.Entries.Add(entry);
            }
        }
开发者ID:shizacat,项目名称:gibbedtr,代码行数:29,代码来源:BigFileV3.cs

示例4: Deserialize

        public void Deserialize(Stream input, Endian endianness)
        {
            if (input.Length < 20)
            {
                throw new FormatException("bad section header size?");
            }

            var count0 = input.ReadValueU32(endianness);
            var count1 = input.ReadValueU32(endianness);
            var count2 = input.ReadValueU32(endianness);
            var count3 = input.ReadValueU32(endianness);
            var count4 = input.ReadValueU32(endianness);

            this.LocalDataResolvers.Clear();
            for (uint i = 0; i < count0; i++)
            {
                var unknown = new LocalDataResolver();
                unknown.Deserialize(input);
                this.LocalDataResolvers.Add(unknown);
            }

            this.RemoteDataResolvers.Clear();
            for (uint i = 0; i < count1; i++)
            {
                var unknown = new RemoteDataResolver();
                unknown.Deserialize(input);
                this.RemoteDataResolvers.Add(unknown);
            }

            this.Unknown2s.Clear();
            for (uint i = 0; i < count2; i++)
            {
                var unknown = new Unknown2Resolver();
                unknown.Deserialize(input);
                this.Unknown2s.Add(unknown);
            }

            this.Unknown3s.Clear();
            if (count3 > 0)
                throw new NotSupportedException();
            //for (uint i = 0; i < count3; i++)
            //{
            //    var a = input.ReadValueU32();
            //    this.Unknown3s.Add(a);
            //}

            this.Unknown4s.Clear();
            for (uint i = 0; i < count4; i++)
            {
                var unknown = new Unknown4Resolver();
                unknown.Deserialize(input);
                this.Unknown4s.Add(unknown);
            }
        }
开发者ID:shizacat,项目名称:gibbedtr,代码行数:54,代码来源:Resolver.cs

示例5: Deserialize

        public void Deserialize(Stream input)
        {
            if (input.ReadValueU32(false) != 0x626D6174)
            {
                throw new FormatException();
            }

            uint count = input.ReadValueU32();
            this.Unknown0.Clear();
            for (uint i = 0; i < count; i++)
            {
                var unknown0 = new Subtype1();
                unknown0.Deserialize(input);
                this.Unknown0.Add(unknown0);
            }
        }
开发者ID:dhk-room101,项目名称:da2_toolset,代码行数:16,代码来源:BMAT.cs

示例6: Deserialize

        public void Deserialize(Stream input)
        {
            input.Seek(0, SeekOrigin.Begin);

            var header = input.ReadStructure<SimGroup.FileHeader>();

            if (header.HeaderSize < Marshal.SizeOf(header) ||
                header.HeaderSize > input.Length)
            {
                throw new FormatException("bad data size");
            }

            uint[] unknown08s = new uint[header.Unknown14Count];
            input.Seek(header.Unknown08Offset, SeekOrigin.Begin);
            for (ushort i = 0; i < header.Unknown14Count; i++)
            {
                unknown08s[i] = input.ReadValueU32();
            }

            input.Seek(header.Unknown0COffset, SeekOrigin.Begin);
            for (ushort i = 0; i < header.Unknown16Count; i++)
            {

            }
        }
开发者ID:tgp1994,项目名称:Gibbed.Visceral,代码行数:25,代码来源:SimGroupFile.cs

示例7: Deserialize

 public void Deserialize(Stream input)
 {
     if (input.ReadValueU32() != 4)
     {
         throw new FormatException("unsupported script version");
     }
 }
开发者ID:shizacat,项目名称:gibbedtr,代码行数:7,代码来源:ScriptSection.cs

示例8: ReadString

 private static string ReadString(Stream input)
 {
     var length = input.ReadValueU32();
     if (length >= 1024)
     {
         throw new InvalidOperationException();
     }
     return input.ReadString(length, true, Encoding.ASCII);
 }
开发者ID:dhk-room101,项目名称:da2_toolset,代码行数:9,代码来源:BMAT.cs

示例9: Deserialize

        public void Deserialize(Stream input)
        {
            var fileAlignment = input.ReadValueU32(true);
            if (fileAlignment != 0x7FF00000 &&
                fileAlignment != 0x0000F07F &&
                fileAlignment != 0x62300000 &&
                fileAlignment != 0x00003062)
            {
                throw new FormatException("unexpected file alignment (should have been 0x7FF00000)");
            }

            this.LittleEndian =
                fileAlignment == 0x7FF00000 ||
                fileAlignment == 0x62300000;
            this.FileAlignment = this.LittleEndian == true ?
                fileAlignment : fileAlignment.Swap();

            this.BasePath = input.ReadString(64, true, Encoding.ASCII);

            var count = input.ReadValueU32(this.LittleEndian);

            var hashes = new uint[count];
            for (uint i = 0; i < count; i++)
            {
                hashes[i] = input.ReadValueU32(this.LittleEndian);
            }

            this.Entries.Clear();
            for (uint i = 0; i < count; i++)
            {
                var entry = new Big.Entry();
                entry.NameHash = hashes[i];
                entry.UncompressedSize = input.ReadValueU32(this.LittleEndian);
                entry.Offset = input.ReadValueU32(this.LittleEndian);
                entry.Locale = input.ReadValueU32(this.LittleEndian);
                entry.CompressedSize = input.ReadValueU32(this.LittleEndian);
                this.Entries.Add(entry);

                if (entry.CompressedSize != 0)
                {
                    throw new NotSupportedException();
                }
            }
        }
开发者ID:shizacat,项目名称:gibbedtr,代码行数:44,代码来源:BigFileV2.cs

示例10: Deserialize

        public static object Deserialize(Stream input, FieldType type, bool littleEndian)
        {
            switch (type)
            {
                case FieldType.UInt8: return input.ReadValueU8();
                case FieldType.Int8: return input.ReadValueS8();
                case FieldType.UInt16: return input.ReadValueU16(littleEndian);
                case FieldType.Int16: return input.ReadValueS16(littleEndian);
                case FieldType.UInt32: return input.ReadValueU32(littleEndian);
                case FieldType.Int32: return input.ReadValueS32(littleEndian);
                case FieldType.UInt64: return input.ReadValueU64(littleEndian);
                case FieldType.Int64: return input.ReadValueS64(littleEndian);
                case FieldType.Single: return input.ReadValueF32(littleEndian);
                case FieldType.Double: return input.ReadValueF64(littleEndian);
                case FieldType.Vector3:
                {
                    var value = new Builtins.Vector3();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
                case FieldType.Vector4:
                {
                    var value = new Builtins.Vector4();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
                case FieldType.Quaternion:
                {
                    var value = new Builtins.Quaternion();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
                case FieldType.String:
                {
                    throw new NotSupportedException("cannot deserialize strings via Builtin");
                }
                case FieldType.Color:
                {
                    var value = new Builtins.Color();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
                case FieldType.Matrix4x4:
                {
                    var value = new Builtins.Matrix4x4();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
            }

            throw new NotSupportedException("unsupported builtin type");
        }
开发者ID:dhk-room101,项目名称:da2_toolset,代码行数:52,代码来源:Builtin.cs

示例11: Deserialize

        public void Deserialize(Stream input)
        {
            this.Version = input.ReadValueU32();
            if (this.Version < 1 || this.Version > 2)
            {
                throw new FormatException("unsupported blob version");
            }

            var nameLength = this.Version == 2 ? 32u : 14u;

            var count = input.ReadValueU32();
            this.Entries = new List<Entry>();
            for (uint i = 0; i < count; i++)
            {
                // ReSharper disable UseObjectOrCollectionInitializer
                var entry = new Entry();
                // ReSharper restore UseObjectOrCollectionInitializer
                entry.Name = input.ReadString(nameLength, true);
                entry.Offset = input.ReadValueU32();
                entry.Size = input.ReadValueU32();
                this.Entries.Add(entry);
            }
        }
开发者ID:gibbed,项目名称:Gibbed.Infantry,代码行数:23,代码来源:BlobFile.cs

示例12: LoadME3save

        void LoadME3save(Stream file)
        {
            if (file != null)
            {
                if (file.ReadValueU32(Endian.Big) == 0x434F4E20)
                {
                    return;
                }
                file.Seek(-4, SeekOrigin.Current);

                try
                {
                    me3Save = Gibbed.MassEffect3.FileFormats.SFXSaveGameFile.Read(file);
                }
                catch (Exception)
                {
                    return;
                }
            }
        }
开发者ID:Juvidoh,项目名称:me3-lazarus,代码行数:20,代码来源:Main.cs

示例13: Deserialize

 public void Deserialize(Stream input, Endian endian)
 {
     this.Size = input.ReadValueU32(endian);
     this.Flags = input.ReadValueEnum<HeaderFlags>(endian);
     this.Height = input.ReadValueS32(endian);
     this.Width = input.ReadValueS32(endian);
     this.PitchOrLinearSize = input.ReadValueU32(endian);
     this.Depth = input.ReadValueU32(endian);
     this.MipMapCount = input.ReadValueU32(endian);
     if (input.Read(this.Reserved1, 0, this.Reserved1.Length) != this.Reserved1.Length)
     {
         throw new EndOfStreamException();
     }
     this.PixelFormat.Deserialize(input, endian);
     this.SurfaceFlags = input.ReadValueU32(endian);
     this.CubemapFlags = input.ReadValueU32(endian);
     if (input.Read(this.Reserved2, 0, this.Reserved2.Length) != this.Reserved2.Length)
     {
         throw new EndOfStreamException();
     }
 }
开发者ID:gibbed,项目名称:Gibbed.Squish,代码行数:21,代码来源:Header.cs

示例14: Deserialize

        public void Deserialize(Stream input)
        {
            input.Seek(0, SeekOrigin.Begin);

            var magic = input.ReadValueU32(false);
            if (magic != 0x42494748) // BIGH
            {
                throw new FormatException("unknown magic");
            }

            this.TotalFileSize = input.ReadValueU32(true); // :wtc:
            uint fileCount = input.ReadValueU32(false);
            uint headerSize = input.ReadValueU32(false);

            this.Entries.Clear();
            var duplicateNames = new List<uint>();
            for (uint i = 0; i < fileCount; i++)
            {
                var entry = new Entry();
                entry.Offset = input.ReadValueU32(false);
                entry.Size = input.ReadValueU32(false);
                entry.Name = input.ReadValueU32(false);

                if (duplicateNames.Contains(entry.Name) == true)
                {
                    entry.Duplicate = true;
                }
                else
                {
                    entry.Duplicate = false;
                    duplicateNames.Add(entry.Name);
                }

                this.Entries.Add(entry);
            }
        }
开发者ID:tgp1994,项目名称:Gibbed.Visceral,代码行数:36,代码来源:BigFile.cs

示例15: Compress

        /// <summary>
        ///     compress an entire ME3 pcc into a byte array.
        /// </summary>
        /// <param name="uncompressedPcc">uncompressed pcc stream.</param>
        /// <returns>a compressed array of bytes.</returns>
        public static Stream Compress(Stream uncompressedPcc)
        {
            uncompressedPcc.Position = 0;

            var magic = uncompressedPcc.ReadValueU32(Endian.Little);
            if (magic != 0x9E2A83C1 &&
                magic.Swap() != 0x9E2A83C1)
            {
                throw new FormatException("not a pcc package");
            }
            var endian = magic == 0x9E2A83C1 ?
                Endian.Little : Endian.Big;
            var encoding = endian == Endian.Little ?
                Encoding.Unicode : Encoding.BigEndianUnicode;

            var versionLo = uncompressedPcc.ReadValueU16(endian);
            var versionHi = uncompressedPcc.ReadValueU16(endian);

            if (versionLo != 684 &&
                versionHi != 194)
            {
                throw new FormatException("unsupported version");
            }

            uncompressedPcc.Seek(4, SeekOrigin.Current);

            var folderNameLength = uncompressedPcc.ReadValueS32(endian);
            var folderNameByteLength =
                folderNameLength >= 0 ? folderNameLength : (-folderNameLength * 2);
            uncompressedPcc.Seek(folderNameByteLength, SeekOrigin.Current);

            var packageFlagsOffset = uncompressedPcc.Position;
            var packageFlags = uncompressedPcc.ReadValueU32(endian);

            if ((packageFlags & 8) != 0)
            {
                uncompressedPcc.Seek(4, SeekOrigin.Current);
            }

            var nameCount = uncompressedPcc.ReadValueU32(endian);
            var namesOffset = uncompressedPcc.ReadValueU32(endian);
            var exportCount = uncompressedPcc.ReadValueU32(endian);
            var exportInfosOffset = uncompressedPcc.ReadValueU32(endian);
            SortedDictionary<uint, uint> exportDataOffsets = new SortedDictionary<uint, uint>();

            Stream data;
            if ((packageFlags & 0x02000000) == 0)
            {
                data = uncompressedPcc;
            }
            else
            {
                throw new FormatException("pcc data is compressed");
            }

            // get info about export data, sizes and offsets
            data.Seek(exportInfosOffset, SeekOrigin.Begin);
            for (uint i = 0; i < exportCount; i++)
            {
                var classIndex = data.ReadValueS32(endian);
                data.Seek(4, SeekOrigin.Current);
                var outerIndex = data.ReadValueS32(endian);
                var objectNameIndex = data.ReadValueS32(endian);
                data.Seek(16, SeekOrigin.Current);

                uint exportDataSize = data.ReadValueU32(endian);
                uint exportDataOffset = data.ReadValueU32(endian);
                exportDataOffsets.Add(exportDataOffset, exportDataSize);

                data.Seek(4, SeekOrigin.Current);
                var count = data.ReadValueU32(endian);
                data.Seek(count * 4, SeekOrigin.Current);
                data.Seek(20, SeekOrigin.Current);
            }

            const uint maxBlockSize = 0x100000;
            Stream outputStream = new MemoryStream();
            // copying pcc header
            byte[] buffer = new byte[130];
            uncompressedPcc.Seek(0, SeekOrigin.Begin);
            uncompressedPcc.Read(buffer, 0, 130);
            outputStream.Write(buffer, 0, buffer.Length);

            //add compressed pcc flag
            uncompressedPcc.Seek(12, SeekOrigin.Begin);
            folderNameLength = uncompressedPcc.ReadValueS32();
            folderNameByteLength =
                folderNameLength >= 0 ? folderNameLength : (-folderNameLength * 2);
            uncompressedPcc.Seek(folderNameByteLength, SeekOrigin.Current);
            outputStream.Seek(uncompressedPcc.Position, SeekOrigin.Begin);

            packageFlags = uncompressedPcc.ReadValueU32();
            packageFlags |= 0x02000000; // add compression flag
            outputStream.WriteValueU32(packageFlags);

//.........这里部分代码省略.........
开发者ID:ME3Explorer,项目名称:ME3Explorer,代码行数:101,代码来源:CompressionHelper.cs


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