本文整理汇总了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;
}
示例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);
}
}
示例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));
}
}
示例4: ImportFromNumber
protected override object ImportFromNumber(ImportContext context, JsonReader reader)
{
return reader.ReadNumber();
}
示例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;
}
}
}
}
示例6: ImportFromNumber
protected override object ImportFromNumber(ImportContext context, JsonReader reader)
{
return new byte[] { reader.ReadNumber().ToByte() };
}