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


C# EndianBinaryReader.ReadInt16方法代码示例

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


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

示例1: read

		public void read(EndianBinaryReader r) {
			Time = r.ReadSingle();
			Measure = r.ReadInt16();
			Beat = r.ReadInt16();
			PhraseIteration = r.ReadInt32();
			Mask = r.ReadInt32();
		}
开发者ID:aequitas,项目名称:rocksmith-custom-song-toolkit,代码行数:7,代码来源:Sng2014HSL.cs

示例2: testWriteString16_emptystring

        public void testWriteString16_emptystring()
        {
            // test that a null string writes no output.
            MemoryStream stream = new MemoryStream();
            EndianBinaryWriter writer = new EndianBinaryWriter(stream);
            writer.WriteString16("");

            stream.Seek(0, SeekOrigin.Begin);
            EndianBinaryReader reader = new EndianBinaryReader(stream);
            Assert.AreEqual(0, reader.ReadInt16());
        }
开发者ID:ThorTech,项目名称:apache-nms,代码行数:11,代码来源:EndianBinaryWriterTest.cs

示例3: SidReader

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="path">File path to the SID file.</param>
        public SidReader(string path)
        {
            using (var sid = new EndianBinaryReader(File.OpenRead(path), Endian.Big))
            {
                // Get some flag values beforehand
                // Video standard/chip model/BASIC flag
                sid.BaseStream.Seek(0x76, SeekOrigin.Begin);
                short flag = sid.ReadInt16();
                VideoStandard = GetVideoStandard(flag);
                ChipModel = GetChipModel(flag);
                IsBasicFlagSet = BasicFlagIsSet(flag);
                sid.BaseStream.Seek(0x00, SeekOrigin.Begin);

                // Header
                HeaderID = new string(sid.ReadChars(4));

                // Version number (Shift because big-endian)
                Version = sid.ReadInt16();

                // Offset to C64 binary data
                DataOffset = sid.ReadInt16();

                // Addresses
                LoadAddress = GetLoadAddress(sid);
                InitAddress = GetInitAddress(sid);
                PlayAddress = GetPlayAddress(sid);

                // Songs
                Songs = sid.ReadInt16();
                StartSong = sid.ReadInt16();

                // Speed integer
                Speed = sid.ReadInt32();

                // Song, Artist and Copyright
                SongTitle = new string(sid.ReadChars(32));
                Artist = new string(sid.ReadChars(32));
                Copyright = new string(sid.ReadChars(32));
            }
        }
开发者ID:lioncash,项目名称:GameMusicInfoLib,代码行数:44,代码来源:SidReader.cs

示例4: Read

        public static SlotItem Read(EndianBinaryReader r)
        {
            SlotItem i = new SlotItem();
            
            i.ItemID = (BlockID)r.ReadInt16();
            if (i.ItemID < 0)
                return null;
            #if DEBUGPACKET
            if (((int)i.ItemID).ToString() == i.ItemID.ToString())
                throw new NotImplementedException("BlockID: " + (int)i.ItemID);
            #endif

            i.Count = r.ReadByte();
            i.Uses = r.ReadInt16();

            //Metadata   
            i.Data = Tag.ReadTag(r);
            //Debug.WriteLine(i + ": " + i.Data);

            return i;

        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:22,代码来源:SlotItem.cs

示例5: Load

        public static Type Load(Stream stream)
        {
            var reader = new EndianBinaryReader(EndianBitConverter.Big, stream);

            int magic = reader.ReadInt32();

            short minorVersion = reader.ReadInt16();
            short majorVersion = reader.ReadInt16();

            List<CompileConstant> constants = new List<CompileConstant>(ReadConstants(reader));

            var modifiers = (ClassModifier)reader.ReadInt16();

            short thisClass = reader.ReadInt16();
            short superClass = reader.ReadInt16();

            IEnumerable<short> interfaces = ReadInterfaces(reader);
            IEnumerable<CompileFieldInfo> fields = ReadFields(reader, constants);
            IEnumerable<CompileMethodInfo> methods = ReadMethods(reader, constants);
            CompileAttribute[] attributes = ReadAttributes(reader, constants);

            var c = new Class
                        {
                            Name = GetClass(thisClass, constants).Name,
                            Modifiers = modifiers,
                            Super = (superClass == 0 ? null : GetClass(superClass, constants)) as Class
                        };

            c.Interfaces.AddRange(interfaces.Select(x => GetClass(x, constants)).OfType<Interface>());
            c.Fields.AddRange(fields.Select(x => GetField(c, x, constants)));

            List<Method> javaMethods = methods.Select(x => GetMethod(c, x, constants)).ToList();

            c.Methods.AddRange(javaMethods.Where(x => x.Name != "<init>"));
            c.Constructors.AddRange(javaMethods.Where(x => x.Name == "<init>").Select(x => (Constructor)x));

            return c;
        }
开发者ID:will14smith,项目名称:JavaCompiler,代码行数:38,代码来源:ClassLoader.cs

示例6: GetGroups

        public static List<Group> GetGroups(EndianBinaryReader reader, int numGroups)
        {
            List<Group> groups = new List<Group>();
            for (int i = 0; i < numGroups; i++)
            {
                Group group = new Group();

                group.boneID = reader.ReadInt16();
                group.lastVertex = reader.ReadUInt16();

                groups.Add(group);
            }
            return groups;
        }
开发者ID:MercurialForge,项目名称:VSViewer,代码行数:14,代码来源:VSToolsMeshParser.cs

示例7: STAG

 public STAG(EndianBinaryReader er)
 {
     Signature = er.ReadString(Encoding.ASCII, 4);
     if (Signature != "STAG") throw new SignatureNotCorrectException(Signature, "STAG", er.BaseStream.Position - 4);
     Unknown1 = er.ReadUInt16();
     NrLaps = er.ReadInt16();
     Unknown2 = er.ReadByte();
     FogEnabled = er.ReadByte() == 1;
     FogTableGenMode = er.ReadByte();
     FogSlope = er.ReadByte();
     UnknownData1 = er.ReadBytes(0x8);
     FogDensity = er.ReadFx32();
     FogColor = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     FogAlpha = er.ReadUInt16();
     KclColor1 = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     KclColor2 = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     KclColor3 = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     KclColor4 = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     FrustumFar = er.ReadFx32();
     UnknownData2 = er.ReadBytes(0x4);
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:21,代码来源:STAG.cs

示例8: GetJoints

        public static List<Joint> GetJoints(EndianBinaryReader reader, int numJoints)
        {
            List<Joint> joints = new List<Joint>();

            for (int i = 0; i < numJoints; i++)
            {
                Joint joint = new Joint();
                joint.boneLength = -reader.ReadInt16();

                reader.Skip(2); // no effect on length, just padding

                joint.parentID = reader.ReadSByte();
                joint.x = reader.ReadSByte();
                joint.y = reader.ReadSByte();
                joint.z = reader.ReadSByte();
                joint.mode = reader.ReadSByte(); // does this matter?

                reader.Skip(0x01); // unknown
                reader.Skip(0x06); // always 0? padding?

                joints.Add(joint);
            }
            return joints;
        }
开发者ID:MercurialForge,项目名称:VSViewer,代码行数:24,代码来源:VSToolsMeshParser.cs

示例9: Read

        public void Read(Stream stream)
        {
            var reader = new EndianBinaryReader(EndianBitConverter.Big, stream);

            var magic = reader.ReadInt32();

            var minorVersion = reader.ReadInt16();
            var majorVersion = reader.ReadInt16();

            ReadConstants(reader);

            Modifiers = (ClassModifier)reader.ReadInt16();

            ThisClass = reader.ReadInt16();
            SuperClass = reader.ReadInt16();

            Name = GetClass(ThisClass).GetDescriptor(true);

            ReadInterfaces(reader);
            ReadFields(reader);
            ReadMethods(reader);
            Attributes = ReadAttributes(reader);
        }
开发者ID:will14smith,项目名称:JavaCompiler,代码行数:23,代码来源:CompileTypeInfo.cs

示例10: GetVertices

        public static List<Vertex> GetVertices(EndianBinaryReader reader, List<Group> groups)
        {
            List<Vertex> vertices = new List<Vertex>();
            for (int i = 0, g = 0; i < groups[groups.Count - 1].lastVertex; i++)
            {
                if (i >= groups[g].lastVertex)
                {
                    g++; // next group
                }

                Vertex vertex = new Vertex();

                vertex.x = reader.ReadInt16();
                vertex.y = reader.ReadInt16();
                vertex.z = reader.ReadInt16();

                reader.Skip(0x02); // padding

                vertex.groupID = g;
                vertex.boneID = groups[g].boneID;

                vertices.Add(vertex);
            }
            return vertices;
        }
开发者ID:MercurialForge,项目名称:VSViewer,代码行数:25,代码来源:VSToolsMeshParser.cs

示例11: Read

        public void Read(EndianBinaryReader reader, string type, List<EntityTemplate> templates)
        {
            ChunkType = type;

            if (ChunkType == "RTBL")
            {
            }

            DisplayName = ChunkType;

            Fields = new List<ElementProperty>();

            string searchID = ChunkType.Remove(ChunkType.Length - 1);

            EntityTemplate template = templates.Find(x => x.ChunkID.Contains(searchID));

            Geometry = template.Geometry;

            ActualColor = template.Color;

            DisplayColor = ActualColor;

            foreach (ElementProperty prop in template.Properties)
            {
                switch (prop.Type)
                {
                    case FieldType.Byte:
                        prop.Data = reader.ReadByte();
                        break;
                    case FieldType.Short:
                        prop.Data = reader.ReadInt16();
                        break;
                    case FieldType.Integer:
                        prop.Data = reader.ReadInt32();
                        break;
                    case FieldType.Float:
                        prop.Data = reader.ReadSingle();
                        break;
                    case FieldType.Vector2:
                        prop.Data = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                        break;
                    case FieldType.Vector3:
                        prop.Data = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                        if (prop.Name == "Position")
                        {
                            Position = (Vector3)prop.Data;
                        }
                        break;
                    case FieldType.String:
                        string test = reader.ReadString((uint)prop.Length).Trim('\0');
                        prop.Data = test;
                        DisplayName = (string)prop.Data;
                        break;
                    case FieldType.ListByte:
                        List<byte> byteList = new List<byte>();

                        int readerOffsetStorage = (int)reader.BaseStream.Position;

                        if (ChunkType == "RTBL")
                        {
                            int roomListOffset = (int)template.Properties.Find(x => x.Name == "Room List Offset").Data;

                            readerOffsetStorage = (int)reader.BaseStream.Position;

                            reader.BaseStream.Position = roomListOffset;

                            prop.Length = Convert.ToInt32(template.Properties.Find(x => x.Name == "Room Count").Data);
                        }

                        for (int i = 0; i < prop.Length; i++)
                        {
                            byteList.Add(reader.ReadByte());
                        }

                        prop.Data = byteList;

                        if (ChunkType == "RTBL")
                        {
                            reader.BaseStream.Position = readerOffsetStorage;
                        }
                        break;
                    case FieldType.ListShort:
                        List<short> shortList = new List<short>();

                        for (int i = 0; i < prop.Length; i++)
                        {
                            shortList.Add(reader.ReadInt16());
                        }

                        prop.Data = shortList;
                        break;
                    case FieldType.ListRPPN:
                        List<Chunk> rppnList = new List<Chunk>();

                        prop.Data = rppnList;
                        break;
                    case FieldType.Color:
                        Color color = Color.FromArgb((int)reader.ReadByte(), (int)reader.ReadByte(), (int)reader.ReadByte());

//.........这里部分代码省略.........
开发者ID:Sage-of-Mirrors,项目名称:DZxEditor-TWW-Entity-Editor,代码行数:101,代码来源:Main.cs

示例12: LoadMapEntityFromStream

        private RawMapEntity LoadMapEntityFromStream(string chunkFourCC, EndianBinaryReader reader, MapEntityDataDescriptor template)
        {
            RawMapEntity obj = new RawMapEntity();
            obj.Fields = new PropertyCollection();
            obj.FourCC = chunkFourCC;

            // We're going to examine the Template's properties and load based on the current template type.
            for (int i = 0; i < template.Fields.Count; i++)
            {
                var templateProperty = template.Fields[i];
                string propertyName = templateProperty.FieldName;
                PropertyType type = templateProperty.FieldType;
                object value = null;

                switch (type)
                {
                    case PropertyType.FixedLengthString:
                        value = reader.ReadString(templateProperty.Length).Trim(new[] { '\0' });
                        break;

                    case PropertyType.String:
                        value = reader.ReadStringUntil('\0');
                        break;

                    case PropertyType.Byte:
                        value = reader.ReadByte();
                        break;

                    case PropertyType.Short:
                        value = reader.ReadInt16();
                        break;

                    case PropertyType.Int32BitField:
                    case PropertyType.Int32:
                        value = reader.ReadInt32();
                        break;

                    case PropertyType.Float:
                        value = reader.ReadSingle();
                        break;

                    case PropertyType.Vector3:
                        value = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                        break;

                    case PropertyType.Vector2:
                        value = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                        break;

                    case PropertyType.Enum:
                        byte enumIndexBytes = reader.ReadByte(); // ToDo: Resolve to actual Enum later.
                        value = enumIndexBytes;
                        break;

                    case PropertyType.ObjectReference:
                        // When we first resolve them, we're going to keep the value as the reference byte,
                        // and then when they are post-processed they'll be turned into a proper type.
                        value = (int)reader.ReadByte();
                        break;

                    case PropertyType.ObjectReferenceShort:
                        // When we first resolve them, we're going to keep the value as the reference byte,
                        // and then when they are post-processed they'll be turned into a proper type.
                        value = (int)reader.ReadUInt16();
                        break;

                    case PropertyType.ObjectReferenceArray:
                        // When we first resolve them, we're going to keep the value as the reference byte,
                        // and then when they are post-processed they'll be turned into a proper type.
                        var refList = new BindingList<object>();
                        for (int refArray = 0; refArray < templateProperty.Length; refArray++)
                        {
                            refList.Add((int)reader.ReadByte());
                        }
                        value = refList;
                        break;

                    case PropertyType.XYRotation:
                        {
                            Vector3 eulerAngles = new Vector3();
                            for (int f = 0; f < 2; f++)
                                eulerAngles[f] = (reader.ReadInt16() * (180 / 32786f));

                            Quaternion xAxis = Quaternion.FromAxisAngle(new Vector3(1, 0, 0), eulerAngles.X * MathE.Deg2Rad);
                            Quaternion yAxis = Quaternion.FromAxisAngle(new Vector3(0, 1, 0), eulerAngles.Y * MathE.Deg2Rad);

                            // Swizzling to the ZYX order seems to be the right one.
                            Quaternion finalRot = yAxis * xAxis;
                            value = finalRot;
                        }
                        break;

                    case PropertyType.XYZRotation:
                        {
                            Vector3 eulerAngles = new Vector3();
                            for (int f = 0; f < 3; f++)
                                eulerAngles[f] = (reader.ReadInt16() * (180 / 32786f));

                            Quaternion xAxis = Quaternion.FromAxisAngle(new Vector3(1, 0, 0), eulerAngles.X * MathE.Deg2Rad);
                            Quaternion yAxis = Quaternion.FromAxisAngle(new Vector3(0, 1, 0), eulerAngles.Y * MathE.Deg2Rad);
//.........这里部分代码省略.........
开发者ID:CryZe,项目名称:WindEditor2,代码行数:101,代码来源:MapEntityLoader.cs

示例13: Read

        public void Read(Stream inStream, MesgDefinition defnMesg)
        {
            inStream.Position = 1;
             EndianBinaryReader mesgReader = new EndianBinaryReader(inStream, defnMesg.IsBigEndian);

             LocalNum = defnMesg.LocalMesgNum;

             foreach (FieldDefinition fieldDef in defnMesg.GetFields())
             {
            // It's possible the field type found in the field definition may
            // not agree with the type defined in the profile.  The profile
            // type will be preferred for decode.
            Field field = GetField(fieldDef.Num);
            if (field == null)
            {
               // We normally won't have fields attached to our skeleton message,
               // as we add values we need to add the fields too based on the mesg,field
               // combo in the profile.  Must derive from the profile so the scale etc
               // is correct
               field = new Field(Profile.GetMesg(this.Num).GetField(fieldDef.Num));
               if (field.Num == Fit.FieldNumInvalid)
               {
                  // If there was no info in the profile the FieldNum will get set to invalid
                  // so preserve the unknown fields info while we know it
                  field.Num = fieldDef.Num;
                  field.Type = fieldDef.Type;
               }
               SetField(field);
            }

            object value;

            // strings may be an array and are of variable length
            if ((field.Type & Fit.BaseTypeNumMask) == Fit.String)
            {
               List<byte> utf8Bytes = new List<byte>();
               byte b = new byte();

               for (int i=0; i<fieldDef.Size; i++)
               {
                  b = mesgReader.ReadByte();
                  if (b == 0x00)
                  {
                     field.AddValue(utf8Bytes.ToArray());
                     utf8Bytes.Clear();
                  }
                  else
                  {
                     utf8Bytes.Add(b);
                  }
               }
               if (utf8Bytes.Count != 0)
               {
                  field.AddValue(utf8Bytes.ToArray());
                  utf8Bytes.Clear();
               }
            }
            else
            {
               int numElements = (int)fieldDef.Size / Fit.BaseType[field.Type & Fit.BaseTypeNumMask].size;
               for (int i=0; i < numElements; i++)
               {
                  switch (field.Type & Fit.BaseTypeNumMask)
                  {
                     case Fit.Enum:
                     case Fit.Byte:
                     case Fit.UInt8:
                     case Fit.UInt8z:
                        value = mesgReader.ReadByte();
                        break;

                     case Fit.SInt8:
                        value = mesgReader.ReadSByte();
                        break;

                     case Fit.SInt16:
                        value = mesgReader.ReadInt16();
                        break;

                     case Fit.UInt16:
                     case Fit.UInt16z:
                        value = mesgReader.ReadUInt16();
                        break;

                     case Fit.SInt32:
                        value = mesgReader.ReadInt32();
                        break;

                     case Fit.UInt32:
                     case Fit.UInt32z:
                        value = mesgReader.ReadUInt32();
                        break;

                     case Fit.Float32:
                        value = mesgReader.ReadSingle();
                        break;

                     case Fit.Float64:
                        value = mesgReader.ReadDouble();
                        break;
//.........这里部分代码省略.........
开发者ID:LightningBugalugs,项目名称:Fickle-Frostbite,代码行数:101,代码来源:Mesg.cs

示例14: read

 public void read(EndianBinaryReader r)
 {
     Time = r.ReadSingle();
     Step = r.ReadSingle();
     Unk3_0 = r.ReadInt16();
     Unk4_0 = r.ReadByte();
     Unk5 = r.ReadByte();
 }
开发者ID:cozy1,项目名称:rocksmith-custom-song-toolkit,代码行数:8,代码来源:Sng2014HSL.cs

示例15: ReadFaceMaterialsBlock

        private void ReadFaceMaterialsBlock(EndianBinaryReader reader, CModel currentModel)
        {
            int nbrFaceMaterials = reader.ReadInt32();
            int bytesPerEntry = reader.ReadInt32();

            for (int i = 0; i < nbrFaceMaterials; i++)
            {
                int matIndex = reader.ReadInt16() - 1;   //-1 because it is 1-based
                currentModel.Polygons[i].MaterialIndex = matIndex;
            }
        }
开发者ID:sikora507,项目名称:OpenC1,代码行数:11,代码来源:DatFile.cs


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