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


C# IBinaryReader.ReadShort方法代码示例

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


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

示例1: ProcessChar

        internal virtual ControlCode ProcessChar(IBinaryReader reader, StringBuilder sb, ref int count)
        {
            short ch = reader.ReadShort();
            count++;

            ControlCode code = controlCodes.FirstOrDefault(cc => cc.Code == ch);

            if (code != null)
            {
                if (code.Code != -1)
                {
                    sb.Append('[');

                    if (code.Tag != null)
                    {
                        sb.Append(code.Tag);
                    }
                    else
                    {
                        sb.Append(((ushort)ch).ToString("X4"));
                    }

                    for (int i = 0; i < code.Arguments; i++)
                    {
                        ch = reader.ReadShort();
                        count++;

                        sb.Append(' ');
                        sb.Append(((ushort)ch).ToString("X4"));
                    }

                    sb.Append(']');
                }
            }
            else
            {
                if (charLookup.ContainsKey(ch))
                {
                    sb.Append(charLookup[ch]);
                }
                else
                {
                    sb.Append('[');
                    sb.Append(((ushort)ch).ToString("X4"));
                    sb.Append(']');
                }
            }

            return code;
        }
开发者ID:ChrisBlueStone,项目名称:RopeSnake,代码行数:50,代码来源:StringReader.cs

示例2: ReadCodedStringInternal

        internal string ReadCodedStringInternal(IBinaryReader reader, int? maxLength)
        {
            StringBuilder sb = new StringBuilder();
            int count = 0;

            for (count = 0; (!maxLength.HasValue) ||
                (maxLength.HasValue && count < maxLength);)
            {
                ControlCode code = ProcessChar(reader, sb, ref count);

                if (code != null && code.Flags.HasFlag(ControlCodeFlags.Terminate))
                {
                    break;
                }
            }

            // Advance the position past the end of the string if applicable
            while (maxLength.HasValue && count++ < maxLength)
            {
                reader.ReadShort();
            }

            return sb.ToString();
        }
开发者ID:ChrisBlueStone,项目名称:RopeSnake,代码行数:24,代码来源:JapaneseStringReader.cs

示例3: ReadCodedStringInternal

        internal string ReadCodedStringInternal(IBinaryReader reader, int? maxLength)
        {
            StringBuilder sb = new StringBuilder();
            int count = 0;

            for (count = 0; (!maxLength.HasValue) ||
                (maxLength.HasValue && count < maxLength);)
            {
                // Check for custom codes
                ushort peek = reader.PeekUShort();
                byte upper = (byte)((peek >> 8) & 0xFF);

                if (upper == 0xEF)
                {
                    // Custom code with one-byte argument inline
                    reader.ReadByte();
                    byte arg = reader.ReadByte();
                    count++;

                    sb.Append($"[EF{arg:X2}]");
                }

                else if (peek == 0xFEFF)
                {
                    // Custom code (hot springs) with two-byte argument following
                    reader.ReadShort();
                    ushort arg = reader.ReadUShort();
                    count += 2;

                    sb.Append($"[HOTSPRING {arg:X4}]");
                }

                else
                {
                    ControlCode code = ProcessChar(reader, sb, ref count);

                    if (code != null && code.Flags.HasFlag(ControlCodeFlags.Terminate))
                    {
                        break;
                    }
                }
            }

            // Advance the position past the end of the string if applicable
            while (maxLength.HasValue && count++ < maxLength)
            {
                reader.ReadShort();
            }

            return sb.ToString();
        }
开发者ID:ChrisBlueStone,项目名称:RopeSnake,代码行数:51,代码来源:EnglishStringReader.cs

示例4: ReadBinary

            public void ReadBinary(IBinaryReader reader)
            {
                Assert.AreEqual(1, reader.ReadByte("Byte"));
                Assert.AreEqual(new byte[] {1}, reader.ReadByteArray("ByteArray"));
                Assert.AreEqual('1', reader.ReadChar("Char"));
                Assert.AreEqual(new[] {'1'}, reader.ReadCharArray("CharArray"));
                Assert.AreEqual(1, reader.ReadShort("Short"));
                Assert.AreEqual(new short[] {1}, reader.ReadShortArray("ShortArray"));
                Assert.AreEqual(1, reader.ReadInt("Int"));
                Assert.AreEqual(new[] {1}, reader.ReadIntArray("IntArray"));
                Assert.AreEqual(1, reader.ReadLong("Long"));
                Assert.AreEqual(new long[] {1}, reader.ReadLongArray("LongArray"));
                Assert.AreEqual(true, reader.ReadBoolean("Boolean"));
                Assert.AreEqual(new[] {true}, reader.ReadBooleanArray("BooleanArray"));
                Assert.AreEqual(1, reader.ReadFloat("Float"));
                Assert.AreEqual(new float[] {1}, reader.ReadFloatArray("FloatArray"));
                Assert.AreEqual(1, reader.ReadDouble("Double"));
                Assert.AreEqual(new double[] {1}, reader.ReadDoubleArray("DoubleArray"));
                Assert.AreEqual(1, reader.ReadDecimal("Decimal"));
                Assert.AreEqual(new decimal?[] {1}, reader.ReadDecimalArray("DecimalArray"));
                Assert.AreEqual(Date, reader.ReadTimestamp("Timestamp"));
                Assert.AreEqual(new DateTime?[] {Date}, reader.ReadTimestampArray("TimestampArray"));
                Assert.AreEqual("1", reader.ReadString("String"));
                Assert.AreEqual(new[] {"1"}, reader.ReadStringArray("StringArray"));
                Assert.AreEqual(Guid, reader.ReadGuid("Guid"));
                Assert.AreEqual(new Guid?[] {Guid}, reader.ReadGuidArray("GuidArray"));
                Assert.AreEqual(MyEnum.Bar, reader.ReadEnum<MyEnum>("Enum"));
                Assert.AreEqual(new[] {MyEnum.Bar}, reader.ReadEnumArray<MyEnum>("EnumArray"));

                var raw = reader.GetRawReader();

                Assert.AreEqual(1, raw.ReadByte());
                Assert.AreEqual(new byte[] { 1 }, raw.ReadByteArray());
                Assert.AreEqual('1', raw.ReadChar());
                Assert.AreEqual(new[] { '1' }, raw.ReadCharArray());
                Assert.AreEqual(1, raw.ReadShort());
                Assert.AreEqual(new short[] { 1 }, raw.ReadShortArray());
                Assert.AreEqual(1, raw.ReadInt());
                Assert.AreEqual(new[] { 1 }, raw.ReadIntArray());
                Assert.AreEqual(1, raw.ReadLong());
                Assert.AreEqual(new long[] { 1 }, raw.ReadLongArray());
                Assert.AreEqual(true, raw.ReadBoolean());
                Assert.AreEqual(new[] { true }, raw.ReadBooleanArray());
                Assert.AreEqual(1, raw.ReadFloat());
                Assert.AreEqual(new float[] { 1 }, raw.ReadFloatArray());
                Assert.AreEqual(1, raw.ReadDouble());
                Assert.AreEqual(new double[] { 1 }, raw.ReadDoubleArray());
                Assert.AreEqual(1, raw.ReadDecimal());
                Assert.AreEqual(new decimal?[] { 1 }, raw.ReadDecimalArray());
                Assert.AreEqual(Date, raw.ReadTimestamp());
                Assert.AreEqual(new DateTime?[] { Date }, raw.ReadTimestampArray());
                Assert.AreEqual("1", raw.ReadString());
                Assert.AreEqual(new[] { "1" }, raw.ReadStringArray());
                Assert.AreEqual(Guid, raw.ReadGuid());
                Assert.AreEqual(new Guid?[] { Guid }, raw.ReadGuidArray());
                Assert.AreEqual(MyEnum.Bar, raw.ReadEnum<MyEnum>());
                Assert.AreEqual(new[] { MyEnum.Bar }, raw.ReadEnumArray<MyEnum>());
            }
开发者ID:vladisav,项目名称:ignite,代码行数:58,代码来源:BinaryReaderWriterTest.cs

示例5: ReadBinary

 /** <inheritDoc /> */
 public void ReadBinary(IBinaryReader reader)
 {
     Byte = reader.ReadByte("Byte");
     ByteArray = reader.ReadByteArray("ByteArray");
     Char = reader.ReadChar("Char");
     CharArray = reader.ReadCharArray("CharArray");
     Short = reader.ReadShort("Short");
     ShortArray = reader.ReadShortArray("ShortArray");
     Int = reader.ReadInt("Int");
     IntArray = reader.ReadIntArray("IntArray");
     Long = reader.ReadLong("Long");
     LongArray = reader.ReadLongArray("LongArray");
     Boolean = reader.ReadBoolean("Boolean");
     BooleanArray = reader.ReadBooleanArray("BooleanArray");
     Float = reader.ReadFloat("Float");
     FloatArray = reader.ReadFloatArray("FloatArray");
     Double = reader.ReadDouble("Double");
     DoubleArray = reader.ReadDoubleArray("DoubleArray");
     Decimal = reader.ReadDecimal("Decimal");
     DecimalArray = reader.ReadDecimalArray("DecimalArray");
     Date = reader.ReadTimestamp("Date");
     DateArray = reader.ReadTimestampArray("DateArray");
     String = reader.ReadString("String");
     StringArray = reader.ReadStringArray("StringArray");
     Guid = reader.ReadObject<Guid>("Guid");
     GuidArray = reader.ReadGuidArray("GuidArray");
 }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:28,代码来源:TestModel.cs


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