本文整理汇总了C#中Newtonsoft.Json.Linq.JProperty.Children方法的典型用法代码示例。如果您正苦于以下问题:C# JProperty.Children方法的具体用法?C# JProperty.Children怎么用?C# JProperty.Children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JProperty
的用法示例。
在下文中一共展示了JProperty.Children方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportMessage
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;
}
}
}
}
示例2: GetAggFieldType
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);
}
示例3: ImportData
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;
}
}
}
}
}
}
}
示例4: TypeFromGeoJson
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);
}
}
}
}
示例5: ParseUpdate
/// <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;
}
示例6: ParseMsg
/// <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;
}
示例7: GetVersion
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;
}
}
}
示例8: SetVersion
private static void SetVersion(string version, JProperty dependency)
{
var child = dependency.Children().First();
if (child.HasValues)
{
child["version"] = version;
}
else
{
dependency.Value = version;
}
}