當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。