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


C# BinaryWriter.WriteLpString方法代码示例

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


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

示例1: Write

        public void Write(BinaryWriter writer, IEnumerable<string> materials)
        {
            writer.Write(materials.Count());

            foreach (string material in materials)
            {
                writer.WriteLpString(material);
            }
        }
开发者ID:DamienHauta,项目名称:NS2-Map-Extract,代码行数:9,代码来源:MaterialSerializer.cs

示例2: Write

        public void Write(BinaryWriter writer)
        {
            writer.WriteBooleanAsInt32(IsPartOfALayer);
            if (IsPartOfALayer)
            {
                writer.Write(LayerDeclaration);
                writer.Write(LayerMasks.Count());
                foreach (uint mask in LayerMasks)
                {
                    writer.Write(mask);
                }
            }

            writer.Write(GroupId);

            writer.WriteLpString(EntityName);
            foreach (var pair in Fields)
            {
                writer.Write(NewAttributeDeclaration);
                TypeSerializer.Write(writer, pair.Key, pair.Value);
            }
        }
开发者ID:DamienHauta,项目名称:NS2-Map-Extract,代码行数:22,代码来源:EntityInstance.cs

示例3: Write

        public void Write(BinaryWriter writer, string name, IType type)
        {
            long sizePosition = writer.BaseStream.Position;
            writer.Seek(4, SeekOrigin.Current);
            long startPos = writer.BaseStream.Position;
            writer.WriteLpString(name);
            writer.Write(type.TypeId);
            writer.Write(type.NumFields);
            writer.Write(0);
            type.Write(writer);
            long endPos = writer.BaseStream.Position;

            int length = (int)(endPos - startPos);
            writer.Seek((int)sizePosition, SeekOrigin.Begin);
            writer.Write(length);
            writer.Seek((int)endPos, SeekOrigin.Begin);
        }
开发者ID:DamienHauta,项目名称:NS2-Map-Extract,代码行数:17,代码来源:TypeSerializer.cs

示例4: BinaryWriter_WriteLpString

        public void BinaryWriter_WriteLpString()
        {
            byte[] writtenData;
            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream))
                {
                    writer.WriteLpString("hello world");
                }
                writtenData = stream.ToArray();
            }

            byte[] expected = { 0x0B, 0x00, 0x00, 0x00, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64 };

            Assert.AreEqual(BitConverter.ToString(expected), BitConverter.ToString(writtenData));
            Assert.AreEqual(expected.Length, writtenData.Length);
        }
开发者ID:DamienHauta,项目名称:NS2-Map-Extract,代码行数:17,代码来源:ExtensionsTests.cs


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