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


C# BinaryReader.GetRemainingLength方法代码示例

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


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

示例1: Parse

        public static MvdDocument Parse(Stream stream)
        {
            var rt = new MvdDocument();
            var systemEncoding = Encoding.GetEncoding(932);

            // leave open
            var br = new BinaryReader(stream);
            var header = ReadMvdString(br, 30, systemEncoding);

            if (header != DisplayName)
                throw new InvalidOperationException("invalid format");

            rt.Version = br.ReadSingle();

            if (rt.Version >= 2)
                throw new NotSupportedException("specified format version not supported");

            switch (br.ReadByte())
            {
                case 0:
                    rt.Encoding = Encoding.Unicode;

                    break;
                case 1:
                default:
                    rt.Encoding = Encoding.UTF8;

                    break;
            }

            while (br.GetRemainingLength() > 1)
                rt.Objects.Add(MvdObject.Parse(rt, br));

            return rt;
        }
开发者ID:mfakane,项目名称:Keystone,代码行数:35,代码来源:MvdDocument.cs

示例2: ReadExtensionRegion

        protected override void ReadExtensionRegion(MvdDocument document, MvdObject obj, BinaryReader br)
        {
            if (br.GetRemainingLength() >= 4)
                this.StageCount = br.ReadInt32();

            if (this.MinorType >= 2)
                this.ParentClipId = br.ReadInt32();
        }
开发者ID:mfakane,项目名称:Keystone,代码行数:8,代码来源:MvdBoneData.cs

示例3: ReadExtensionRegion

        protected override void ReadExtensionRegion(MvdDocument document, MvdObject obj, BinaryReader br)
        {
            if (br.GetRemainingLength() >= 4)
                this.IKBones = Enumerable.Range(0, br.ReadInt32()).Select(_ => br.ReadInt32()).ToArray();

            if (this.MinorType >= 3)
                this.ModelRelationCount = br.ReadInt32();
        }
开发者ID:mfakane,项目名称:Keystone,代码行数:8,代码来源:MvdModelPropertyData.cs

示例4: Parse

        public static MvdProjectFrame Parse(MvdProjectData pd, BinaryReader br)
        {
            var rt = new MvdProjectFrame
            {
                FrameTime = br.ReadInt64(),
            };

            if (pd.MinorType >= 1)
            {
                rt.Gravity = br.ReadSingle();
                rt.GravityVector = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), };
            }

            rt.SelfShadowModel = (MvdSelfShadowModel)br.ReadInt32();
            rt.SelfShadowDistance = br.ReadSingle();

            if (pd.MinorType >= 1 || br.GetRemainingLength() >= 4)
                rt.SelfShadowDeep = br.ReadSingle();

            return rt;
        }
开发者ID:mfakane,项目名称:Keystone,代码行数:21,代码来源:MvdProjectFrame.cs

示例5: Parse

        public static MvdObject Parse(MvdDocument document, BinaryReader br)
        {
            var rt = new MvdObject();

            rt.ObjectName = document.Encoding.GetString(br.ReadSizedBuffer());
            rt.EnglishObjectName = document.Encoding.GetString(br.ReadSizedBuffer());
            rt.KeyFps = br.ReadSingle();
            br.ReadSizedBuffer();	// reservedSize / reserved

            while (br.GetRemainingLength() > 1)
            {
                var section = MvdSection.Parse(document, rt, br);

                if (section == null)
                    break;

                rt.Sections.Add(section);
            }

            return rt;
        }
开发者ID:mfakane,项目名称:Keystone,代码行数:21,代码来源:MvdObject.cs

示例6: ReadExtensionRegion

 protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br)
 {
     if (br.GetRemainingLength() >= 4)
         this.IKBones = Enumerable.Range(0, br.ReadInt32()).Select(_ => br.ReadInt32()).ToArray();
 }
开发者ID:ZeusAFK,项目名称:Keystone,代码行数:5,代码来源:MvdModelPropertyData.cs

示例7: ReadExtensionRegion

 protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br)
 {
     if (br.GetRemainingLength() >= 4)
         this.StageCount = br.ReadInt32();
 }
开发者ID:ZeusAFK,项目名称:Keystone,代码行数:5,代码来源:MvdCameraData.cs

示例8: ReadExtensionRegion

 protected override void ReadExtensionRegion(MvdDocument document, MvdObject obj, BinaryReader br)
 {
     if (br.GetRemainingLength() >= 4)
         this.Parameters = Enumerable.Range(0, br.ReadInt32()).Select(_ => MvdEffectParameter.Parse(br)).ToList();
 }
开发者ID:mfakane,项目名称:Keystone,代码行数:5,代码来源:MvdEffectPropertyData.cs

示例9: Parse

        public static VmdDocument Parse(Stream stream)
        {
            var rt = new VmdDocument();
            // leave open
            var br = new BinaryReader(stream);
            var header = ReadVmdString(br, 30);

            if (header == "Vocaloid Motion Data file")
                rt.Version = VmdVersion.MMDVer2;
            else if (header == "Vocaloid Motion Data 0002")
                rt.Version = VmdVersion.MMDVer3;
            else
                throw new InvalidOperationException("invalid format");

            rt.ModelName = ReadVmdString(br, rt.Version == VmdVersion.MMDVer2 ? 10 : 20);

            rt.BoneFrames = ReadBoneFrames(br).ToList();
            rt.MorphFrames = ReadMorphFrames(br).ToList();
            rt.CameraFrames = ReadCameraFrames(br, rt.Version).ToList();
            rt.LightFrames = ReadLightFrames(br).ToList();

            if (br.GetRemainingLength() > 4)
                rt.SelfShadowFrames = ReadSelfShadowFrames(br).ToList();

            if (br.GetRemainingLength() > 4)
                rt.PropertyFrames = ReadPropertyFrames(br).ToList();

            return rt;
        }
开发者ID:mfakane,项目名称:Keystone,代码行数:29,代码来源:VmdDocument.cs

示例10: Parse

        public static MvdDocument Parse(Stream stream)
        {
            var rt = new MvdDocument();
            var systemEncoding = Encoding.GetEncoding(932);

            // leave open
            var br = new BinaryReader(stream);
            var header = ReadMvdString(br, 30, systemEncoding);

            if (header != DisplayName)
                throw new InvalidOperationException("invalid format");

            rt.Version = br.ReadSingle();

            if (rt.Version >= 2)
                throw new NotSupportedException("specified format version not supported");

            switch (br.ReadByte())
            {
                case 0:
                    rt.Encoding = Encoding.Unicode;

                    break;
                case 1:
                default:
                    rt.Encoding = Encoding.UTF8;

                    break;
            }

            rt.ObjectName = rt.Encoding.GetString(br.ReadSizedBuffer());
            br.ReadSizedBuffer();	// objectNameSize2 / objectName2
            rt.KeyFps = br.ReadSingle();
            br.ReadSizedBuffer();	// reservedSize / reserved

            while (br.GetRemainingLength() > 1)
            {
                var section = MvdSection.Parse(rt, br);

                if (section == null)
                    break;

                rt.Sections.Add(section);
            }

            return rt;
        }
开发者ID:ZeusAFK,项目名称:Keystone,代码行数:47,代码来源:MvdDocument.cs

示例11: Parse

        public static PmdDocument Parse(Stream stream)
        {
            var rt = new PmdDocument();

            // leave open
            var br = new BinaryReader(stream);
            var header = ReadPmdString(br, 3);

            if (header != "Pmd")
                throw new InvalidOperationException("invalid format");

            rt.Version = br.ReadSingle();

            if (rt.Version >= 2)
                throw new NotSupportedException("specified format version not supported");

            rt.ModelName = ReadPmdString(br, 20);
            rt.Description = ReadPmdString(br, 256);

            for (var i = br.ReadInt32() - 1; i >= 0; i--)
                rt.Vertices.Add(PmdVertex.Parse(br));

            for (var i = br.ReadInt32() - 1; i >= 0; i--)
                rt.Indices.Add(br.ReadUInt16());

            for (var i = br.ReadInt32() - 1; i >= 0; i--)
                rt.Materials.Add(PmdMaterial.Parse(br));

            var bones = br.ReadUInt16();

            for (ushort i = 0; i < bones; i++)
                rt.Bones.Add(PmdBone.Parse(br));

            for (var i = br.ReadUInt16() - 1; i >= 0; i--)
                rt.IK.Add(PmdIK.Parse(br));

            var morphs = br.ReadUInt16();

            for (ushort i = 0; i < morphs; i++)
                rt.Morphs.Add(PmdMorph.Parse(br));

            for (var i = br.ReadByte() - 1; i >= 0; i--)
                rt.VisibleMorphs.Add(br.ReadUInt16());

            var visibleBoneCategories = br.ReadByte();

            for (byte i = 0; i < visibleBoneCategories; i++)
                rt.VisibleBoneCategories.Add(ReadPmdString(br, 50));

            for (var i = br.ReadInt32() - 1; i >= 0; i--)
                rt.VisibleBones.Add(br.ReadInt16(), br.ReadByte());

            if (br.GetRemainingLength() > 0)
            {
                rt.EnglishCompatible = br.ReadBoolean();

                if (rt.EnglishCompatible)
                {
                    rt.EnglishModelName = ReadPmdString(br, 20);
                    rt.EnglishDescription = ReadPmdString(br, 256);

                    for (ushort i = 0; i < bones; i++)
                        rt.EnglishBoneNames.Add(ReadPmdString(br, 20));

                    for (ushort i = 0; i < morphs - 1; i++)
                        rt.EnglishMorphNames.Add(ReadPmdString(br, 20));

                    for (byte i = 0; i < visibleBoneCategories; i++)
                        rt.EnglishVisibleBoneCategories.Add(ReadPmdString(br, 50));
                }

                if (br.GetRemainingLength() > 0)
                    rt.ToonFileNames = Enumerable.Range(0, 10).Select(_ => ReadPmdString(br, 100)).ToList();

                if (br.GetRemainingLength() > 0)
                {
                    for (var i = br.ReadInt32() - 1; i >= 0; i--)
                        rt.Rigids.Add(PmdRigidBody.Parse(br));

                    for (var i = br.ReadInt32() - 1; i >= 0; i--)
                        rt.Constraints.Add(PmdConstraint.Parse(br));
                }
            }

            return rt;
        }
开发者ID:ZeusAFK,项目名称:Keystone,代码行数:86,代码来源:PmdDocument.cs

示例12: Parse

        public static PmdDocument Parse(Stream stream)
        {
            var rt = new PmdDocument();

            // leave open
            var br = new BinaryReader(stream);
            var header = ReadPmdString(br, 3);

            if (header != "Pmd")
                throw new InvalidOperationException("invalid format");

            rt.Version = br.ReadSingle();

            if (rt.Version >= 2)
                throw new NotSupportedException("specified format version not supported");

            rt.ModelName = ReadPmdString(br, 20);
            rt.Description = ReadPmdString(br, 256);

            for (var i = br.ReadInt32() - 1; i >= 0; i--)
                rt.Vertices.Add(PmdVertex.Parse(br, rt));

            for (var i = br.ReadInt32() - 1; i >= 0; i--)
                rt.Indices.Add(rt.Vertices[br.ReadUInt16()]);

            for (var i = br.ReadInt32() - 1; i >= 0; i--)
                rt.Materials.Add(PmdMaterial.Parse(br));

            Enumerable.Range(0, br.ReadUInt16()).Select(_ =>
            {
                while (rt.Bones.Count <= _)
                    rt.Bones.Add(new PmdBone());

                return rt.Bones[_];
            }).ForEach(_ => _.Parse(br, rt));

            for (var i = br.ReadUInt16() - 1; i >= 0; i--)
                rt.IK.Add(PmdIK.Parse(br, rt));

            var morphs = br.ReadUInt16();
            PmdMorph morphBase = null;

            for (ushort i = 0; i < morphs; i++)
            {
                var m = PmdMorph.Parse(br, rt, morphBase);

                if (m.Kind == PmdMorphKind.None)
                    morphBase = m;
                else
                    rt.Morphs.Add(m);
            }

            for (var i = br.ReadByte() - 1; i >= 0; i--)
                rt.MorphDisplayList.Add(rt.Morphs[br.ReadUInt16() - 1]);

            var visibleBoneCategories = br.ReadByte();

            for (byte i = 0; i < visibleBoneCategories; i++)
                rt.BoneDisplayList.Add(PmdDisplayList.Parse(br));

            for (var i = br.ReadInt32() - 1; i >= 0; i--)
            {
                var bone = rt.Bones[br.ReadInt16()];

                rt.BoneDisplayList[br.ReadByte() - 1].Bones.Add(bone);
            }

            if (br.GetRemainingLength() > 0)
            {
                rt.EnglishCompatible = br.ReadBoolean();

                if (rt.EnglishCompatible)
                {
                    rt.EnglishModelName = ReadPmdString(br, 20);
                    rt.EnglishDescription = ReadPmdString(br, 256);

                    for (ushort i = 0; i < rt.Bones.Count; i++)
                        rt.Bones[i].EnglishName = ReadPmdString(br, 20);

                    for (ushort i = 0; i < morphs - 1; i++)
                        rt.Morphs[i].EnglishName = ReadPmdString(br, 20);

                    for (byte i = 0; i < visibleBoneCategories; i++)
                        rt.BoneDisplayList[i].EnglishName = ReadPmdString(br, 50);
                }

                if (br.GetRemainingLength() > 0)
                    rt.ToonFileNames = Enumerable.Range(0, 10).Select(_ => ReadPmdString(br, 100)).ToList();

                if (br.GetRemainingLength() > 0)
                {
                    for (var i = br.ReadInt32() - 1; i >= 0; i--)
                        rt.Rigids.Add(PmdRigidBody.Parse(br));

                    for (var i = br.ReadInt32() - 1; i >= 0; i--)
                        rt.Constraints.Add(PmdConstraint.Parse(br));
                }
            }

            return rt;
//.........这里部分代码省略.........
开发者ID:mfakane,项目名称:Keystone,代码行数:101,代码来源:PmdDocument.cs


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