本文整理汇总了C#中JsonReader.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# JsonReader.ReadInt32方法的具体用法?C# JsonReader.ReadInt32怎么用?C# JsonReader.ReadInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonReader
的用法示例。
在下文中一共展示了JsonReader.ReadInt32方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializeMeta
private GraphMeta DeserializeMeta (ZipEntry entry) {
if (entry == null) throw new Exception("No metadata found in serialized data.");
#if !ASTAR_NO_JSON
string s = GetString(entry);
var reader = new JsonReader(s, readerSettings);
return (GraphMeta)reader.Deserialize(typeof(GraphMeta));
#else
var meta = new GraphMeta();
var reader = GetBinaryReader(entry);
if (reader.ReadString() != "A*") throw new System.Exception("Invalid magic number in saved data");
int major = reader.ReadInt32();
int minor = reader.ReadInt32();
int build = reader.ReadInt32();
int revision = reader.ReadInt32();
// Required because when saving a version with a field not set, it will save it as -1
// and then the Version constructor will throw an exception (which we do not want)
if (major < 0) meta.version = new Version(0, 0);
else if (minor < 0) meta.version = new Version(major, 0);
else if (build < 0) meta.version = new Version(major, minor);
else if (revision < 0) meta.version = new Version(major, minor, build);
else meta.version = new Version(major, minor, build, revision);
meta.graphs = reader.ReadInt32();
meta.guids = new string[reader.ReadInt32()];
for (int i = 0; i < meta.guids.Length; i++) meta.guids[i] = reader.ReadString();
meta.typeNames = new string[reader.ReadInt32()];
for (int i = 0; i < meta.typeNames.Length; i++) meta.typeNames[i] = reader.ReadString();
meta.nodeCounts = new int[reader.ReadInt32()];
for (int i = 0; i < meta.nodeCounts.Length; i++) meta.nodeCounts[i] = reader.ReadInt32();
return meta;
#endif
}
示例2: TestValue
private static void TestValue(object expected, JsonReader reader, string path)
{
if (JNull.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((JObject) expected, reader, path);
}
else
{
switch (expectedType)
{
case TypeCode.String : Assert.AreEqual(expected, reader.ReadString(), path); break;
case TypeCode.Int32 : Assert.AreEqual(expected, reader.ReadInt32(), path); break;
default : Assert.Fail("Don't know how to handle {0} values.", expected.GetType()); break;
}
}
}
}