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


C# JsonReader.ReadNumber方法代码示例

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


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

示例1: JsonDeserializer

    // Reader
    public static object JsonDeserializer(JsonReader reader)
    {
        var scoreEntry = new RankEntry();

        reader.ReadArrayStart();
        scoreEntry.rankIndex = (int)reader.ReadNumber();
        scoreEntry.accountId = reader.ReadString();
        scoreEntry.name = reader.ReadString();
        scoreEntry.country = reader.ReadString();
        scoreEntry.bestRanking = (int)reader.ReadNumber();
        scoreEntry.totalDamage = (long)reader.ReadNumber();
        reader.ReadArrayEnd();

        return scoreEntry;
    }
开发者ID:judah4,项目名称:battle-of-mages,代码行数:16,代码来源:RankEntry.cs

示例2: ImportFromNumber

        protected override object ImportFromNumber(ImportContext context, JsonReader reader)
        {
            Debug.Assert(context != null);
            Debug.Assert(reader != null);

            try
            {
                return BooleanObject.Box(reader.ReadNumber().ToInt64() != 0);                
            }
            catch (FormatException e)
            {
                throw new JsonException(string.Format("The JSON Number {0} must be an integer to be convertible to System.Boolean.", reader.Text), e);
            }
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:14,代码来源:BooleanImporter.cs

示例3: Import

        public override object Import(ImportContext context, JsonReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            reader.MoveToContent();
            
            if (reader.TokenClass == JsonTokenClass.String)
            {
                return reader.ReadString();
            }
            else if (reader.TokenClass == JsonTokenClass.Number)
            {
                return reader.ReadNumber();
            }
            else if (reader.TokenClass == JsonTokenClass.Boolean)
            {
                return reader.ReadBoolean();
            }
            else if (reader.TokenClass == JsonTokenClass.Null)
            {
                reader.Read();
                return null;
            }
            else if (reader.TokenClass == JsonTokenClass.Array)
            {
                JsonArray items = new JsonArray();
                items.Import(context, reader);
                return items;
            }
            else if (reader.TokenClass == JsonTokenClass.Object)
            {
                JsonObject o = new JsonObject();
                o.Import(context, reader);
                return o;
            }
            else 
            {
                throw new JsonException(string.Format("{0} not expected.", reader.TokenClass));
            }
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:41,代码来源:AutoImporter.cs

示例4: ImportFromNumber

 protected override object ImportFromNumber(ImportContext context, JsonReader reader)
 {
     return reader.ReadNumber();
 }
开发者ID:GroupXTech,项目名称:Yatse2,代码行数:4,代码来源:AnyImporter.cs

示例5: TestValue

        private static void TestValue(object expected, JsonReader reader, string path)
        {
            if (JsonNull.LogicallyEquals(expected))
            {
                Assert.AreEqual(JsonTokenClass.Null, reader.TokenClass, path);
            }
            else
            {
                TypeCode expectedType = Type.GetTypeCode(expected.GetType());

                if (expectedType == TypeCode.Object)
                {
                    if (expected.GetType().IsArray)
                        TestArray((Array) expected, reader, path);
                    else
                        TestObject((JsonObject) expected, reader, path);
                }
                else
                {
                    switch (expectedType)
                    {
                        case TypeCode.String : Assert.AreEqual(expected, reader.ReadString(), path); break;
                        case TypeCode.Int32  : Assert.AreEqual(expected, (int) reader.ReadNumber(), path); break;
                        default : Assert.Fail("Don't know how to handle {0} values.", expected.GetType()); break;
                    }
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:28,代码来源:TestComponentExporter.cs

示例6: ImportFromNumber

 protected override object ImportFromNumber(ImportContext context, JsonReader reader)
 {
     return new byte[] { reader.ReadNumber().ToByte() };
 }
开发者ID:liuxing7954,项目名称:cangku_1,代码行数:4,代码来源:ByteArrayImporter.cs


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