public static DesiredProperties FromJsonObject(JObject timeServiceObject) { DesiredProperties desiredProperties = new DesiredProperties(); foreach (JToken jToken in timeServiceObject.Children()) { if (!(jToken is JProperty)) { continue; } JProperty collectorNode = (JProperty)jToken; // Check if it is query ("?")... if (collectorNode.Name == CommonDataContract.JsonQuery && collectorNode.Value is JValue && collectorNode.Value.Type == JTokenType.String) { desiredProperties.generalReportLevel = ReportLevelFromJsonString(collectorNode.Value.ToString()); } else if (collectorNode.Value is JObject) { desiredProperties.collectors.Add(CollectorDesiredState.FromJsonObject(collectorNode.Name, (JObject)collectorNode.Value)); } } return(desiredProperties); }
public static CollectorDesiredState FromJsonObject(string name, JObject obj) { CollectorDesiredState collector = new CollectorDesiredState(); collector.name = name; collector.reportToDeviceTwin = Utils.GetString(obj, CommonDataContract.JsonReportProperties, CommonDataContract.JsonNoString) == CommonDataContract.JsonYesString; JToken jApplyProperties = Utils.GetJToken(obj, CommonDataContract.JsonApplyProperties); if (jApplyProperties is JObject) { collector.applyFromDeviceTwin = true; collector.collectorInner = CollectorInner.FromJsonObject((JObject)jApplyProperties); } else { collector.applyFromDeviceTwin = false; } return(collector); }