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


C# JsonReader.ReadInt32方法代码示例

本文整理汇总了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
		}
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:40,代码来源:JsonSerializer.cs

示例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;
                    }
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:28,代码来源:TestComponentFormatter.cs


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