public static CollectorReportedState FromJson(string collectorName, JToken jValueToken) { if (!(jValueToken is JObject)) { return(null); } CollectorReportedState collectorReportedState = new CollectorReportedState(); JObject jValueObject = (JObject)jValueToken; collectorReportedState.Name = collectorName; foreach (JToken token in jValueObject.Children()) { if (!(token is JProperty)) { continue; } JProperty jProperty = (JProperty)token; switch (jProperty.Name) { case "traceLogFileMode": collectorReportedState.TraceLogFileMode = (string)jProperty.Value; break; case "logFileSizeLimitMB": collectorReportedState.LogFileSizeLimitMB = (int)jProperty.Value; break; case "logFileFolder": collectorReportedState.LogFileFolder = (string)jProperty.Value; break; case "logFileName": collectorReportedState.LogFileName = (string)jProperty.Value; break; case "started": collectorReportedState.Started = (string)jProperty.Value; break; default: ProviderDesiredState providerReportedState = ProviderDesiredState.ProviderDesiredStateFromJson(jProperty.Name, jProperty.Value); if (providerReportedState != null) { if (collectorReportedState.ProviderList == null) { collectorReportedState.ProviderList = new List <ProviderDesiredState>(); } collectorReportedState.ProviderList.Add(providerReportedState); } break; } } return(collectorReportedState); }
public void FromJson(JObject jRoot) { List <CollectorReportedState> collectors = new List <CollectorReportedState>(); foreach (JProperty property in jRoot.Children()) { CollectorReportedState collectorReportedState = CollectorReportedState.FromJson(property.Name, property.Value); if (collectorReportedState != null) { collectors.Add(collectorReportedState); } } CollectorsConfigurations = collectors; }