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 static ProviderDesiredState ProviderDesiredStateFromJson(string providerName, JToken jValueToken) { if (!(jValueToken is JObject)) { return(null); } JObject jValueObject = (JObject)jValueToken; ProviderDesiredState providerDesiredState = new ProviderDesiredState(); providerDesiredState.Name = providerName; providerDesiredState.TraceLevel = Utils.GetString(jValueObject, "traceLevel", "verbose"); providerDesiredState.Keywords = Utils.GetString(jValueObject, "keywords", "*"); providerDesiredState.Enabled = Utils.GetBool(jValueObject, "enabled", true); providerDesiredState.Type = Utils.GetString(jValueObject, "type", "provider"); return(providerDesiredState); }