Children() public méthode

Returns a collection of the child tokens of this token, in document order.
public Children ( ) : JEnumerable
Résultat JEnumerable
Exemple #1
0
 public void GetButtonMappings(Newtonsoft.Json.Linq.JProperty mapping, string name, ref List <string> list)
 {
     foreach (var item in mapping.Children().FirstOrDefault().SelectTokens(name))
     {
         foreach (var entry in item.Children())
         {
             list.Add(entry.ToString());
         }
     }
 }
	private void ImportMessage (WienerLinienDataModell NewDataModell, JProperty Start)
		{
		foreach (JObject MessageToken in Start.Children())
			{
			foreach (JProperty MessageChildProp in MessageToken.Properties())
				{
				if (MessageChildProp.Name == "value")
					{
					MessageType Output;
					if (Enum.TryParse(MessageChildProp.Value.ToString(), true, out Output))
						NewDataModell.MessType = Output;
					else
						NewDataModell.MessType = MessageType.Error;
					continue;
					}
				if (MessageChildProp.Name == "messageCode")
					{
					NewDataModell.MessageCode = MessageChildProp.Value.ToObject<Int32>();
					continue;
					}
				if (MessageChildProp.Name == "serverTime")
					{
					NewDataModell.ServerTime = MessageChildProp.Value.ToObject<DateTime>();
					continue;
					}
				}
			}
		}
        private Type GetAggFieldType(JProperty agg)
        {
            var child = agg.Children().FirstOrDefault();
            if (child != null)
            {
                var bucketList = child["buckets"];
                if (bucketList != null)
                {
                    var bucket = bucketList.FirstOrDefault();
                    if (bucketList != null)
                    {
                        return GetFieldType(bucket["key"]);
                    }
                }
                else
                {
                    var value = child["value"];
                    if (value != null)
                    {
                        return GetFieldType(value);
                    }
                }
            }

            return typeof(object);
        }
	private void ImportData (WienerLinienDataModell NewDataModell, JProperty Start)
		{
		foreach (JObject MonitorsChild in Start.Children())	//monitors
			{
			foreach (JProperty MonitorsChildProp in MonitorsChild.Properties())
				{
				String PropMonitorName = MonitorsChildProp.Name;
				if (PropMonitorName == "monitors")
					{
					foreach (JObject Entry in MonitorsChildProp.Values())
						{
						LocationStop ActuallLocationStop = null;
						foreach (JProperty PropEntry in Entry.Properties())
							{
							if (PropEntry.Name == "locationStop")
								{
								ActuallLocationStop = ImportLocationStop(NewDataModell, PropEntry);
								continue;
								}
							if (PropEntry.Name == "lines")
								{
								ImportLines(ActuallLocationStop, PropEntry);
								continue;
								}
							}
						}
					}
				}
			}
		}
Exemple #5
0
        public void TypeFromGeoJson(JProperty json)
        {
            MetaInfo = new MetaInfoCollection();
            foreach (var childJ in json.Children().OfType<JObject>())
            {
                JToken tokenS;
                childJ.TryGetValue("style", out tokenS);
                if (tokenS != null)
                {
                    // First, convert the JSON to XML.
                    var styleNode = JsonConvert.DeserializeXmlNode("{style:" + tokenS + "}");
                    var styleDoc = styleNode.ToXDocument();
                    var xElement = styleDoc.Element(XName.Get("style"));
                    if (xElement != null)
                    {
                        // Convert child nodes to attributes.
                        foreach (var el in xElement.Elements())
                        {
                            xElement.Add(new XAttribute(UppercaseFirst(el.Name), (string)el));
                        }
                        xElement.Elements().Remove();
                        // Parse the style.
                        try
                        {
                            var newStyle = new PoIStyle();
                            newStyle.FromXml(xElement, ".", false); // Do not catch exception.
                            Style = newStyle;
                        }
                        catch
                        {
                            // Ok, keep old style.
                        }
                    }
                }

                JToken tokenM;
                childJ.TryGetValue("propertyTypeData", out tokenM);
                if (tokenM != null)
                {
                    var metaInfos = tokenM.Children();
                    foreach (var metaInfo in metaInfos)
                    {
                        var newMetaInfo = new MetaInfo();
                        newMetaInfo.FromGeoJson(metaInfo.ToString(Formatting.None), false);
                        MetaInfo.Add(newMetaInfo);
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// 解析update值
        /// </summary>
        /// <param name="jPropertyUpdateRoot"></param>
        /// <returns></returns>
        Dictionary<string, object> ParseUpdate(JProperty jPropertyUpdateRoot)
        {
            Dictionary<string, object> listData = null;
            foreach (JObject jPropertyObject in jPropertyUpdateRoot.Children())
            {
                listData = ParseJsonStruct(jPropertyObject);
            }

            return listData;
        }
Exemple #7
0
        /// <summary>
        /// 解析msg值
        /// </summary>
        /// <param name="jPropertyMsgRoot"></param>
        /// <returns></returns>
        List<Dictionary<string, object>> ParseMsg(JProperty jPropertyMsgRoot)
        {
            List<Dictionary<string, object>> msgListData = new List<Dictionary<string, object>>();

            foreach (JArray jMsgItem in jPropertyMsgRoot.Children())
            {
                foreach (JObject jMsgObjectRoot in jMsgItem)
                {
                    msgListData.Add(ParseJsonStruct(jMsgObjectRoot));
                }
            }

            return msgListData;
        }
        private static string GetVersion(JProperty dependency)
        {
            var child = dependency.Children().First();

            if (child.HasValues && child["version"] != null)
            {
                return child["version"].Value<string>();
            }
            else
            {
                try
                {
                    return child.Value<string>();
                }
                catch
                {
                    return string.Empty;
                }
            }
        }
 private static void SetVersion(string version, JProperty dependency)
 {
     var child = dependency.Children().First();
     if (child.HasValues)
     {
         child["version"] = version;
     }
     else
     {
         dependency.Value = version;
     }
 }