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


C# JsonReader.PopulateObject方法代码示例

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


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

示例1: DeserializeEditorSettings

        /** Deserializes graph editor settings.
         * For future compatibility this method does not assume that the \a graphEditors array matches the #graphs array in order and/or count.
         * It searches for a matching graph (matching if graphEditor.target == graph) for every graph editor.
         * Multiple graph editors should not refer to the same graph.\n
         * \note Stored in files named "graph#_editor.json" where # is the graph number.
         */
        public void DeserializeEditorSettings(GraphEditorBase[] graphEditors)
        {
            if (graphEditors == null) return;

            for (int i=0;i<graphEditors.Length;i++) {
                if (graphEditors[i] == null) continue;
                for (int j=0;j<graphs.Length;j++) {
                    if (graphs[j] == null || graphEditors[i].target != graphs[j]) continue;

                    ZipEntry entry = zip["graph"+j+"_editor"+jsonExt];
                    if (entry == null) continue;

                    string entryText = GetString (entry);

                    JsonReader reader = new JsonReader(entryText,readerSettings);
                    reader.PopulateObject (graphEditors[i]);
                    break;
                }
            }
        }
开发者ID:rmkeezer,项目名称:fpsgame,代码行数:26,代码来源:JsonSerializer.cs

示例2: DeserializeGraphs

        /** Deserializes graph settings.
         * \note Stored in files named "graph#.json" where # is the graph number.
         */
        public NavGraph[] DeserializeGraphs()
        {
            //for (int j=0;j<1;j++) {
            //System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            //watch.Start();

            graphs = new NavGraph[meta.graphs];

            for (int i=0;i<meta.graphs;i++) {
                Type tp = meta.GetGraphType(i);
                ZipEntry entry = zip["graph"+i+jsonExt];

                if (entry == null)
                    throw new FileNotFoundException ("Could not find data for graph "+i+" in zip. Entry 'graph+"+i+jsonExt+"' does not exist");

                //Debug.Log ("Reading graph " +i+" with type "+tp.FullName);
                String entryText = GetString(entry);
                //Debug.Log (entryText);

                NavGraph tmp = data.CreateGraph(tp);//(NavGraph)System.Activator.CreateInstance(tp);
                JsonReader reader = new JsonReader(entryText,readerSettings);

                //NavGraph graph = tmp.Deserialize(reader);//reader.Deserialize<NavGraph>();
                reader.PopulateObject (tmp);

                graphs[i] = tmp;
                if (graphs[i].guid.ToString () != meta.guids[i])
                    throw new System.Exception ("Guid in graph file not equal to guid defined in meta file. Have you edited the data manually?\n"+graphs[i].guid.ToString()+" != "+meta.guids[i]);

                //NavGraph graph = (NavGraph)JsonConvert.DeserializeObject (entryText,tp,settings);
            }

            return graphs;

            //watch.Stop();
            //Debug.Log ((watch.ElapsedTicks*0.0001).ToString ("0.00"));
            //}
        }
开发者ID:rmkeezer,项目名称:fpsgame,代码行数:41,代码来源:JsonSerializer.cs

示例3: DeserializeGraphs

		/** Deserializes graph settings.
		 * \note Stored in files named "graph#.json" where # is the graph number.
		 */
		public NavGraph[] DeserializeGraphs () {
			// Allocate a list of graphs to be deserialized
			graphs = new NavGraph[meta.graphs];

			int nonNull = 0;

			for (int i=0;i<meta.graphs;i++) {
				// Get the graph type from the metadata we deserialized earlier
				var tp = meta.GetGraphType(i);
				
				// Graph was null when saving, ignore
				if (System.Type.Equals (tp, null)) continue;

				nonNull++;

				var entry = zip["graph"+i+jsonExt];
				
				if (entry == null)
					throw new FileNotFoundException ("Could not find data for graph "+i+" in zip. Entry 'graph+"+i+jsonExt+"' does not exist");

				// Create a new graph of the right type
				NavGraph graph = data.CreateGraph(tp);
				graph.graphIndex = (uint)(i + graphIndexOffset);

#if !ASTAR_NO_JSON
				var entryText = GetString(entry);
					
				var reader = new JsonReader(entryText,readerSettings);

				reader.PopulateObject (ref graph);
				
#else
				var mem = new MemoryStream ();
				entry.Extract(mem);
				mem.Position = 0;
				var reader = new BinaryReader (mem);
				var ctx = new GraphSerializationContext(reader, null, i + graphIndexOffset);
				graph.DeserializeSettings (ctx);
#endif

				graphs[i] = graph;
				if (graphs[i].guid.ToString () != meta.guids[i])
					throw new Exception ("Guid in graph file not equal to guid defined in meta file. Have you edited the data manually?\n"+graphs[i].guid+" != "+meta.guids[i]);
			}

			// Remove any null entries from the list
			var compressed = new NavGraph[nonNull];
			nonNull = 0;
			for ( int i=0;i<graphs.Length;i++) {
				if ( graphs[i] != null ) {
					compressed[nonNull] = graphs[i];
					nonNull++;
				}
			}

			graphs = compressed;

			return graphs;
		}
开发者ID:SpacesAdventure,项目名称:Kio-2,代码行数:62,代码来源:JsonSerializer.cs

示例4: DeserializeGraphs

		/** Deserializes graph settings.
		 * \note Stored in files named "graph#.json" where # is the graph number.
		 */
		public NavGraph[] DeserializeGraphs () {
			
			//for (int j=0;j<1;j++) {
			//System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
			//watch.Start();
			
			graphs = new NavGraph[meta.graphs];

			int nonNull = 0;

			for (int i=0;i<meta.graphs;i++) {
				Type tp = meta.GetGraphType(i);
				
				//Graph was null when saving, ignore
				if (System.Type.Equals (tp, null)) continue;

				nonNull++;

				ZipEntry entry = zip["graph"+i+jsonExt];
				
				if (entry == null)
					throw new FileNotFoundException ("Could not find data for graph "+i+" in zip. Entry 'graph+"+i+jsonExt+"' does not exist");


				NavGraph tmp = data.CreateGraph(tp);//(NavGraph)System.Activator.CreateInstance(tp);

#if !ASTAR_NO_JSON
				String entryText = GetString(entry);
					
				JsonReader reader = new JsonReader(entryText,readerSettings);
				
				//NavGraph graph = tmp.Deserialize(reader);//reader.Deserialize<NavGraph>();
				reader.PopulateObject (ref tmp);
				
#else
				var mem = new MemoryStream ();
				entry.Extract(mem);
				mem.Position = 0;
				var reader = new BinaryReader (mem);
				var ctx = new GraphSerializationContext(reader, null, i);
				tmp.DeserializeSettings (ctx);
#endif

				graphs[i] = tmp;
				if (graphs[i].guid.ToString () != meta.guids[i])
					throw new System.Exception ("Guid in graph file not equal to guid defined in meta file. Have you edited the data manually?\n"+graphs[i].guid.ToString()+" != "+meta.guids[i]);
				
				//NavGraph graph = (NavGraph)JsonConvert.DeserializeObject (entryText,tp,settings);
			}

			NavGraph[] compressed = new NavGraph[nonNull];
			nonNull = 0;
			for ( int i=0;i<graphs.Length;i++) {
				if ( graphs[i] != null ) {
					compressed[nonNull] = graphs[i];
					nonNull++;
				}
			}

			graphs = compressed;

			return graphs;
			
			//watch.Stop();
			//Debug.Log ((watch.ElapsedTicks*0.0001).ToString ("0.00"));
			//}
		}
开发者ID:moderndelta137,项目名称:Shadow_Sword,代码行数:70,代码来源:JsonSerializer.cs

示例5: DeserializeEditorSettings

//#if UNITY_EDITOR
		/** Deserializes graph editor settings.
		 * For future compatibility this method does not assume that the \a graphEditors array matches the #graphs array in order and/or count.
		 * It searches for a matching graph (matching if graphEditor.target == graph) for every graph editor.
		 * Multiple graph editors should not refer to the same graph.\n
		 * \note Stored in files named "graph#_editor.json" where # is the graph number.
		 */
		public void DeserializeEditorSettings (GraphEditorBase[] graphEditors) {
#if !ASTAR_NO_JSON
			if (graphEditors == null) return;
			
			for (var i=0;i<graphEditors.Length;i++) {
				if (graphEditors[i] == null) continue;
				for (var j=0;j<graphs.Length;j++) {
					if (graphs[j] == null || graphEditors[i].target != graphs[j]) continue;
					
					var entry = zip["graph"+j+"_editor"+jsonExt];
					if (entry == null) continue;
					
					var entryText = GetString (entry);
					
					var reader = new JsonReader(entryText,readerSettings);
					var graphEditor = graphEditors[i];
					reader.PopulateObject (ref graphEditor);
					graphEditors[i] = graphEditor;
					break;
				}
			}
#endif
		}
开发者ID:Marchys,项目名称:fanalet,代码行数:30,代码来源:JsonSerializer.cs

示例6: DeserializeGraph

		NavGraph DeserializeGraph (int zipIndex, int graphIndex) {
			// Get the graph type from the metadata we deserialized earlier
			var tp = meta.GetGraphType(zipIndex);

			// Graph was null when saving, ignore
			if (System.Type.Equals(tp, null)) return null;

			var entry = zip["graph"+zipIndex+jsonExt];

			if (entry == null)
				throw new FileNotFoundException("Could not find data for graph "+zipIndex+" in zip. Entry 'graph"+zipIndex+jsonExt+"' does not exist");

			// Create a new graph of the right type
			NavGraph graph = data.CreateGraph(tp);
			graph.graphIndex = (uint)(graphIndex);

#if !ASTAR_NO_JSON
			var entryText = GetString(entry);
			var reader = new JsonReader(entryText, readerSettings);

			// Read the graph settings
			reader.PopulateObject(ref graph);
#else
			var reader = GetBinaryReader(entry);
			var ctx = new GraphSerializationContext(reader, null, graph.graphIndex);
			graph.DeserializeSettings(ctx);
#endif

			if (graph.guid.ToString() != meta.guids[zipIndex])
				throw new Exception("Guid in graph file not equal to guid defined in meta file. Have you edited the data manually?\n"+graph.guid+" != "+meta.guids[zipIndex]);

			return graph;
		}
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:33,代码来源:JsonSerializer.cs


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