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


C# MemoryStream.ReadUInt32方法代码示例

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


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

示例1: Chunk

        internal Chunk(MemoryStream ms)
        {
            Length = Helper.ConvertEndian(ms.ReadUInt32());
            ChunkType = Encoding.ASCII.GetString(ms.ReadBytes(4));
            ChunkData = ms.ReadBytes((int)Length);
            Crc = Helper.ConvertEndian(ms.ReadUInt32());

            ParseData(new MemoryStream(ChunkData));
        }
开发者ID:xupefei,项目名称:APNG.NET,代码行数:9,代码来源:Chunk.cs

示例2: ParseData

 protected override void ParseData(MemoryStream ms)
 {
     SequenceNumber = Helper.ConvertEndian(ms.ReadUInt32());
     Width = Helper.ConvertEndian(ms.ReadUInt32());
     Height = Helper.ConvertEndian(ms.ReadUInt32());
     XOffset = Helper.ConvertEndian(ms.ReadUInt32());
     YOffset = Helper.ConvertEndian(ms.ReadUInt32());
     DelayNum = Helper.ConvertEndian(ms.ReadUInt16());
     DelayDen = Helper.ConvertEndian(ms.ReadUInt16());
     DisposeOp = (DisposeOps)ms.ReadByte();
     BlendOp = (BlendOps)ms.ReadByte();
 }
开发者ID:xupefei,项目名称:APNG.NET,代码行数:12,代码来源:fcTLChunk.cs

示例3: SoundFXObject

        public SoundFXObject(byte[] data)
        {
            Data = data;

            using (MemoryStream s = new MemoryStream(data))
            {
                Header = s.ReadStruct<SoundFXHeader>();
                if (Header.IsStreamed != 0)
                {
                    WemOffset = s.ReadUInt32();
                    WemLength = s.ReadUInt32();
                }
            }

            UInt32 temp = Header.AudioFileId % 0x32;

            Console.WriteLine("SoundFX ID: {0:X8} AudioFileID: {1:X8} SourceId: {2:X8} temp {3:X8}", Header.ID, Header.AudioFileId, Header.SourceId, temp);
        }
开发者ID:rodrigonh,项目名称:ThomasJepp.SaintsRow,代码行数:18,代码来源:SoundFXObject.cs

示例4: HIRCSection

        public HIRCSection(byte[] data)
        {
            Data = data;

            using (MemoryStream s = new MemoryStream(data))
            {
                UInt32 objectCount = s.ReadUInt32();
                for (int i = 0; i < objectCount; i++)
                {
                    Console.Write("HIRC object at: {0:X}", s.Position);
                    HIRCType type = (HIRCType)s.ReadUInt8();
                    UInt32 length = s.ReadUInt32();
                    byte[] buffer = new byte[length];
                    s.Read(buffer, 0, (int)length);

                    Console.WriteLine(" Type {0} Length {1:X}", type, length);

                    IHIRCObject obj = HIRCObject.GetObject(type, buffer);
                    Objects.Add(obj);
                }
            }
        }
开发者ID:rodrigonh,项目名称:ThomasJepp.SaintsRow,代码行数:22,代码来源:HIRCSection.cs

示例5: HashFilename

		public static uint HashFilename(string name, PackageHashType type)
		{
			switch (type)
			{
				case PackageHashType.Classic:
					{
						name = name.ToUpperInvariant();
						if (name.Length % 4 != 0)
							name = name.PadRight(name.Length + (4 - name.Length % 4), '\0');

						using (var ms = new MemoryStream(Encoding.ASCII.GetBytes(name)))
						{
							var len = name.Length >> 2;
							uint result = 0;

							while (len-- != 0)
								result = ((result << 1) | (result >> 31)) + ms.ReadUInt32();

							return result;
						}
					}

				case PackageHashType.CRC32:
					{
						name = name.ToUpperInvariant();
						var l = name.Length;
						var a = l >> 2;
						if ((l & 3) != 0)
						{
							name += (char)(l - (a << 2));
							var i = 3 - (l & 3);
							while (i-- != 0)
								name += name[a << 2];
						}

						return CRC32.Calculate(Encoding.ASCII.GetBytes(name));
					}

				default: throw new NotImplementedException("Unknown hash type `{0}`".F(type));
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:41,代码来源:PackageEntry.cs

示例6: ReadUInt32

        public void ReadUInt32()
        {
            UInt32 testValue = 2048;
            using( var stream = new MemoryStream() )
            {
                var bytes = BitConverter.GetBytes( testValue );
                stream.Write( bytes, 0, bytes.Length );
                stream.Seek( 0, SeekOrigin.Begin );

                var value = stream.ReadUInt32();
                Assert.AreEqual( value, testValue );
            }
        }
开发者ID:akabekobeko,项目名称:Owl,代码行数:13,代码来源:StreamExtentionsTest.cs

示例7: ParseData

 protected override void ParseData(MemoryStream ms)
 {
     SequenceNumber = Helper.ConvertEndian(ms.ReadUInt32());
     FrameData = ms.ReadBytes((int) Length - 4);
 }
开发者ID:mwheeler,项目名称:APNG.NET,代码行数:5,代码来源:fdATChunk.cs

示例8: UnPackArray

		//-------------------------------------------------------------------------------------
		private static void UnPackArray(ref object arr, byte[] data, Type elemType, uint owner, DeserContext cox)
		{
			MemoryStream ms = null;
			try
			{
				ms = new MemoryStream(data);
				int[] dims = new int[ms.ReadByte()];
				for(int a = 0; a < dims.Length; a++)
					dims[a] = ms.ReadInt32();

				arr = Array.CreateInstance(elemType, dims);

				//bool fullDeser = true;

				if(IsPrimitive(elemType))
				{
					#region
					uint size = (uint)SizeOfPrimitive(elemType);
					ArrayIndexEnumerator aie = new ArrayIndexEnumerator((Array)arr);
					while(aie.MoveNext())
						((Array)arr).SetValue(FromBytes(elemType, ms.ReadBytes(size)), aie.Current);
					#endregion
				}
				else if(elemType == typeof(String) || elemType == typeof(RefString))
				{
					#region
					byte b;
					ArrayIndexEnumerator aie = new ArrayIndexEnumerator((Array)arr);
					while(aie.MoveNext())
					{
						using(MemoryStream line = new MemoryStream())
							while(true)
							{
								b = (byte)ms.ReadByte();
								if(b == 0xFE)
									((Array)arr).SetValue(null, aie.Current);
								else if(b == 0xFF)
									((Array)arr).SetValue(FromBytes(elemType, line.ToArray()), aie.Current);
								else
									line.WriteByte(b);
								if(b >= 0xFE)
									break;
							}
					}
					#endregion
				}
				else if(elemType == typeof(Type))
				{
					#region
					ArrayIndexEnumerator aie = new ArrayIndexEnumerator((Array)arr);
					while(aie.MoveNext())
					{
						ushort typeid = ms.ReadUInt16();
						if(typeid != 0)
							((Array)arr).SetValue(cox.types[typeid], aie.Current);
					}
					#endregion
				}
				else
				{
					ArrayIndexEnumerator aie = new ArrayIndexEnumerator((Array)arr);
					while(aie.MoveNext())
					{
						ushort typeid = ms.ReadUInt16();
						if(typeid == 0)
							continue;
						Type t = cox.types[typeid];

						if(t.IsArray)
						{
							object val = null;
							uint len = ms.ReadUInt32();
							UnPackArray(ref val, ms.ReadBytes(len), t.GetElementType(), owner, cox);
							((Array)arr).SetValue(val, aie.Current);
						}
						else if(typeid < 25 || t.IsEnum)
							((Array)arr).SetValue(FromBytes(t, ms.ReadBytes((uint)SizeOfPrimitive(t))), aie.Current);
						else if(t == typeof(String) || t == typeof(RefString))
						{
							#region
							using(MemoryStream line = new MemoryStream())
							{
								byte b;
								while(true)
								{
									b = (byte)ms.ReadByte();
									if(b == 0xFE)
										((Array)arr).SetValue(null, aie.Current);
									else if(b == 0xFF)
										((Array)arr).SetValue(FromBytes(t, line.ToArray()), aie.Current);
									else
										line.WriteByte(b);
									if(b >= 0xFE)
										break;
								}
							}
							#endregion
						}
						else if(typeof(ISelfSerialization).IsAssignableFrom(t))
//.........这里部分代码省略.........
开发者ID:GoldMax,项目名称:Pulsar.NET,代码行数:101,代码来源:PulsarSerializer_Deser.cs

示例9: Decompress

        public static byte[] Decompress(byte[] buffer, int offset, int count)
        {
            if (buffer == null)
                throw new ArgumentNullException();
            if (count < 0)
                throw new FormatException();
            if (offset + count > buffer.Length)
                throw new IndexOutOfRangeException();

            using (MemoryStream buffStream = new MemoryStream(buffer, offset, count))
            {
                InflaterInputStream zipStream;
                uint magicStream = buffStream.ReadUInt32();
                if (magicStream != magic)
                {
                    throw new InvalidDataException("found an invalid zlib block");
                }

                uint buffMaxSegmentSize = buffStream.ReadUInt32();
                if (buffMaxSegmentSize != maxSegmentSize)
                {
                    throw new FormatException();
                }

                uint totComprSize = buffStream.ReadUInt32();
                uint totUncomprSize = buffStream.ReadUInt32();

                byte[] outputBuffer = new byte[totUncomprSize];
                int numOfSegm = (int)Math.Ceiling((double)totUncomprSize / (double)maxSegmentSize);
                int headSegm = 16;
                int dataSegm = headSegm + (numOfSegm * 8);
                int buffOff = 0;

                for (int i = 0; i < numOfSegm; i++)
                {
                    buffStream.Seek(headSegm, SeekOrigin.Begin);
                    int comprSegm = buffStream.ReadInt32();
                    int uncomprSegm = buffStream.ReadInt32();
                    headSegm = (int)buffStream.Position;

                    buffStream.Seek(dataSegm, SeekOrigin.Begin);
                    //Console.WriteLine("compr size: {0}, uncompr size: {1}, data offset: 0x{2:X8}", comprSegm, uncomprSegm, dataSegm);
                    zipStream = new InflaterInputStream(buffStream);
                    zipStream.Read(outputBuffer, buffOff, uncomprSegm);
                    zipStream.Flush();
                    buffOff += uncomprSegm;
                    dataSegm += comprSegm;
                }
                buffStream.Close();
                return outputBuffer;
            }
        }
开发者ID:KFreon,项目名称:KFreons-ME3Explorer,代码行数:52,代码来源:ZlibBlock.cs

示例10: ParseData

 protected override void ParseData(MemoryStream ms)
 {
     NumFrames = Helper.ConvertEndian(ms.ReadUInt32());
     NumPlays = Helper.ConvertEndian(ms.ReadUInt32());
 }
开发者ID:xupefei,项目名称:APNG.NET,代码行数:5,代码来源:acTLChunk.cs

示例11: SwitchContainerObject

        public SwitchContainerObject(byte[] data)
        {
            Data = data;

            using (MemoryStream s = new MemoryStream(data))
            {
                ID = s.ReadUInt32();
                bool overrideEffects = s.ReadBoolean();
                byte effectCount = s.ReadUInt8();
                if (effectCount > 0)
                {
                    s.ReadUInt8(); // effectmask
                }
                for (int i = 0; i < effectCount; i++)
                {
                    s.ReadUInt8(); // effect index
                    s.ReadUInt32(); // effect id
                    s.ReadUInt16(); // zeroes
                }
                OutputBus = s.ReadUInt32();
                ParentObjectId = s.ReadUInt32();
                s.ReadBoolean(); // overrideParentPlaybackPriority
                s.ReadBoolean(); // offset priority by ... at max distance activated
                
                byte additionalParameterCount = s.ReadUInt8();
                byte[] additionalParameterTypes = new byte[additionalParameterCount];
                for (int i = 0; i < additionalParameterCount; i++)
                {
                    additionalParameterTypes[i] = s.ReadUInt8();
                }
                for (int i = 0; i < additionalParameterCount; i++)
                {
                    s.ReadUInt32(); // most of these are floats but it doesn't actually matter. 4 bytes is 4 bytes
                }

                s.ReadUInt8(); // unknown

                bool positioningSection = s.ReadBoolean();
                if (positioningSection)
                {
                    byte positionType = s.ReadUInt8();
                    if (positionType == 0x00)
                    {
                        // 2D
                        s.ReadBoolean(); // panner enabled?
                    }
                    else if (positionType == 0x01)
                    {
                        // 3D
                        uint positionSource = s.ReadUInt32();
                        s.ReadUInt32(); // attenuation object
                        s.ReadBoolean(); // spatialization?
                        if (positionSource == 0x02)
                        {
                            // User defined
                            s.ReadUInt32(); // play type
                            s.ReadBoolean(); // loop? 
                            s.ReadUInt32(); // transition time
                            s.ReadBoolean(); // follow listener orientation?
                        }
                        else if (positionSource == 0x03)
                        {
                            // Game defined
                            s.ReadBoolean(); // update at each frame?
                        }
                    }
                }

                s.ReadBoolean(); // override parent settings for Game-Defined Auxiliary Sends?
                s.ReadBoolean(); // use Game-Defined Auxiliary Sends?
                s.ReadBoolean(); // override parent settings for User-Defined Auxiliary Sends?
                bool udasExist = s.ReadBoolean(); // User-Defined Auxiliary Sends exist?
                if (udasExist)
                {
                    uint auxBus0 = s.ReadUInt32(); // Auxiliary bus 0
                    uint auxBus1 = s.ReadUInt32(); // Auxiliary bus 1
                    uint auxBus2 = s.ReadUInt32(); // Auxiliary bus 2
                    uint auxBus3 = s.ReadUInt32(); // Auxiliary bus 3
                }
                
                bool unkPlaybackLimit = s.ReadBoolean(); // unknown param for playback limit
                if (unkPlaybackLimit)
                {
                    s.ReadUInt8(); // priority equal action
                    s.ReadUInt8(); // limit action
                    s.ReadUInt16(); // limit sound instances to ...
                }

                s.ReadUInt8(); // how to limit source instances
                s.ReadUInt8(); // virtual voice behaviour

                s.ReadBoolean(); // override parent settings for playback limit
                s.ReadBoolean(); // override parent settings for virtual voice

                uint stateGroupCount = s.ReadUInt32();
                for (int i = 0; i < stateGroupCount; i++)
                {
                    uint stateGroupId = s.ReadUInt32();
                    s.ReadUInt8(); // change occurs at
                    ushort statesDifferentFromDefault = s.ReadUInt16();
//.........这里部分代码省略.........
开发者ID:rodrigonh,项目名称:ThomasJepp.SaintsRow,代码行数:101,代码来源:SwitchContainerObject.cs


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