public static MonitoringConfig Load(XmlReader reader) { MonitoringConfig result = new MonitoringConfig(); reader.GoToElement(); reader.ReadStartElement(); if (!reader.IsEmptyElement) { while (reader.GoToSibling()) { switch (reader.LocalName) { case "Diagnostics": result.DiagnosticsConfig = DiagnosticsConfig.Load(reader); break; case "Logging": result.LoggingConfig = LoggingConfig.Load(reader); break; case "AdditionalData": string kvps = reader.ReadElementContentAsString(); foreach (var item in kvps.Split(',')) { var kvp = item.Split('='); result.AdditionalData.Add(kvp[0], kvp[1]); } break; default: reader.Skip(); break; } } } return result; }
/// <summary> /// Loads a new instance of the EdgeServerRules class from Xml. /// </summary> /// <param name="reader"></param> /// <returns></returns> public static EdgeServerRules Load(XmlReader reader) { if (reader == null) throw new ArgumentNullException("reader"); var result = new EdgeServerRules(); reader.GoToElement(); if (!reader.IsEmptyElement) { result.Domain = reader.GetAttribute("Domain"); reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "EdgeResolverUrlPattern": result.EdgeResolverUrlPattern = reader.ReadElementContentAsString(); break; case "EdgeRegEx": result.EdgeRegex = reader.ReadElementContentAsString(); break; case "ClientIpRegEx": result.ClientIPRegex = reader.ReadElementContentAsString(); break; case "ClientIpHeader": result.ClientIPHeader = reader.ReadElementContentAsString(); break; case "EdgeResolverHeaders": result.EdgeResolverHeaders = reader.ReadElementContentAsString().Split(','); break; case "EdgeHeader": result.EdgeHeader = reader.ReadElementContentAsString(); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); return result; }
/// <summary> /// Loads the configuration from Xml. /// </summary> /// <param name="reader">An XmlReader containing your configuration data.</param> /// <returns>A new instance of a LoggingConfig object.</returns> public static LoggingConfig Load(XmlReader reader) { var result = new LoggingConfig(); reader.GoToElement(); if (!reader.IsEmptyElement) { result.MaxExceptionLength = null; // assume no limit is intended if param is omitted reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "LogUnhandledExceptions": result.LogUnhandledExceptions = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "PreventUnhandledExceptions": result.PreventUnhandledExceptions = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "MaxExceptionLength": result.MaxExceptionLength = reader.ReadElementContentAsInt(); break; case "QueryStringParam": result.QueryStringParam = reader.ReadElementContentAsString(); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); return result; }
/// <summary> /// Creates an instance of the TracingConfig from an Xml file. /// </summary> public static TracingConfig Load(XmlReader reader) { if (reader == null) throw new ArgumentNullException("reader"); var result = new TracingConfig(); reader.GoToElement(); if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "TracingConfigFile": result.TracingConfigFile = reader.ReadElementContentAsString(); break; case "PollingMilliseconds": result.PollingInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt()); break; case "RecordCpuLoad": result.RecordCpuLoad = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); return result; }
public static IEnumerable<KeyValuePairMapping> LoadValues(XmlReader reader) { while (reader.GoToSibling()) { switch (reader.LocalName) { case "Value": yield return KeyValuePairMapping.Load(reader); break; default: reader.Skip(); break; } } }
/// <summary> /// Helper method to deserialize mapping rules form xml /// </summary> public static MappingRules Load(XmlReader reader) { MappingRules result = new MappingRules(); reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "Log": var log = LogMappings.Load(reader); result.LogMappingsRules.Add(log.Type, log); break; default: reader.Skip(); break; } } reader.ReadEndElement(); return result; }
public static IBatchAgent Load(XmlReader reader) { IBatchAgent result = null; reader.GoToElement(); if (!reader.IsEmptyElement) { string url = null; SerializationFormat serializationFormat = SerializationFormat.Unknown; bool isRelative = false; bool isWCF = true; bool binaryBinding = false; bool compress = false; int maxOpenTimeSeconds = 5; int maxSendTimeSeconds = 5; int maxRecvTimeSeconds = 5; int serviceVersion = 3; reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "Url": url = reader.ReadElementContentAsString(); break; case "WCF": isWCF = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "relative": isRelative = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "binaryBinding": binaryBinding = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "maxOpenTimeSeconds": maxOpenTimeSeconds = reader.ReadElementContentAsInt(); break; case "maxSendTimeSeconds": maxSendTimeSeconds = reader.ReadElementContentAsInt(); break; case "maxRecvTimeSeconds": maxRecvTimeSeconds = reader.ReadElementContentAsInt(); break; case "version": serviceVersion = reader.ReadElementContentAsInt(); break; case "compression": compress = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "serializationFormat": var value = reader.ReadElementContentAsString(); if (value.Equals("xml", StringComparison.OrdinalIgnoreCase)) serializationFormat = SerializationFormat.Xml; else if (value.Equals("json", StringComparison.OrdinalIgnoreCase)) serializationFormat = SerializationFormat.Json; else if (value.Equals("httpquerystring", StringComparison.OrdinalIgnoreCase)) serializationFormat = SerializationFormat.HttpQueryString; break; default: reader.Skip(); break; } } reader.ReadEndElement(); // actually create the Uri Uri serviceUri = null; if (url != null) { if (isRelative) #if SILVERLIGHT && !WINDOWS_PHONE serviceUri = new Uri(System.Windows.Application.Current.Host.Source, url); #else throw new NotImplementedException(); #endif else serviceUri = new Uri(url); } if (isWCF) { throw new NotImplementedException(); //TODO: result = new WCFDataClient(serviceUri, binaryBinding, maxOpenTimeSeconds, maxSendTimeSeconds, maxRecvTimeSeconds, serviceVersion); } else { result = new RESTDataClient(serviceUri, maxSendTimeSeconds + maxRecvTimeSeconds, compress, serializationFormat, serviceVersion); } }
/// <summary> /// Helper method to deserialize a batch serailized via the default serialization /// </summary> /// <returns>The deserialized batch</returns> public static Batch Deserialize(XmlReader xmlReader) { if (xmlReader.GoToElement()) { Batch result = new Batch(); LogBase.DeserializeData(xmlReader, result); xmlReader.ReadStartElement(); List<Log> logs = new List<Log>(); while (xmlReader.GoToSibling()) { switch (xmlReader.LocalName) { case Log.LogNodeName: var log = Log.Deserialize(xmlReader); logs.Add(log); break; default: xmlReader.Skip(); break; } } result.Logs = logs; xmlReader.ReadEndElement(); return result; } else throw new Exception("Batch is empty"); }
public static QualityConfig Load(XmlReader reader) { if (reader == null) throw new ArgumentNullException("reader"); QualityConfig result = new QualityConfig(); reader.GoToElement(); if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "DroppedFrames": result.DroppedFrames = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "RenderedFrames": result.RenderedFrames = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "ProcessCPULoad": result.ProcessCpuLoad = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "SystemCPULoad": result.SystemCpuLoad = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "Bitrate": result.Bitrate = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "BitrateMax": result.BitrateMax = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "BitrateMaxDuration": result.BitrateMaxDuration = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "PerceivedBandwidth": result.PerceivedBandwidth = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "VideoBufferSize": result.VideoBufferSize = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "AudioBufferSize": result.AudioBufferSize = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "Buffering": result.Buffering = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "BitrateChangeCount": result.BitrateChangeCount = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "VideoDownloadLatency": result.VideoDownloadLatency = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "AudioDownloadLatency": result.AudioDownloadLatency = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "DvrOperationCount": result.DvrOperationCount = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "FullScreenChangeCount": result.FullScreenChangeCount = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "HttpErrorCount": result.HttpErrorCount = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); return result; }
/// <summary> /// Creates an instance of the main diagnostic config object from an XmlReader /// </summary> public static DiagnosticsConfig Load(XmlReader reader) { if (reader == null) throw new ArgumentNullException("reader"); var result = new DiagnosticsConfig(); List<EdgeServerRules> edgeServerRuleCollection = null; reader.GoToElement(); reader.ReadStartElement(); if (!reader.IsEmptyElement) { while (reader.GoToSibling()) { switch (reader.LocalName) { case "TraceMonitor": result.TracingConfig = TracingConfig.Load(reader); break; case "EdgeServerRules": if (!reader.IsEmptyElement) { if (edgeServerRuleCollection == null) { edgeServerRuleCollection = new List<EdgeServerRules>(); result.EdgeServerRuleCollection = edgeServerRuleCollection; } edgeServerRuleCollection.Add(EdgeServerRules.Load(reader)); } else reader.Skip(); break; case "Diagnostics": if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "TrackQuality": result.TrackQuality = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "TrackDownloadErrors": result.TrackDownloadErrors = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "AggregationIntervalMilliseconds": result.AggregationInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt()); break; case "TrackQualitySnapshot": result.TrackQualitySnapshot = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "SnapshotIntervalMilliseconds": result.SnapshotInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt()); break; case "LatencyAlertThreshold": result.LatencyAlertThreshold = reader.ReadElementContentAsFloat(); break; case "RecordTraceLogs": result.RecordTraceLogs = Convert.ToBoolean(reader.ReadElementContentAsInt()); break; case "QualityTracking": result.QualityConfig = QualityConfig.Load(reader); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); return result; }
public static BatchingConfig Load(XmlReader reader) { BatchingConfig result = new BatchingConfig(); reader.GoToElement(); reader.ReadStartElement(); if (!reader.IsEmptyElement) { while (reader.GoToSibling()) { switch (reader.LocalName) { case "Application": if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "Id": result.ApplicationId = new Guid(reader.ReadElementContentAsString()); break; case "Name": result.ApplicationName = reader.ReadElementContentAsString(); break; case "Version": result.ApplicationVersion = reader.ReadElementContentAsString(); break; case "Enabled": result.LoggingEnabled = reader.ReadElementContentAsBoolean(); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); break; case "Queue": if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "maxLength": result.MaxQueueLength = reader.ReadElementContentAsInt(); break; case "maxBatchLength": result.MaxBatchLength = reader.ReadElementContentAsInt(); break; case "maxSendErrors": result.MaxSendErrors = reader.ReadElementContentAsInt(); break; case "maxSendErrorsThrottled": result.MaxSendErrorsThrottled = reader.ReadElementContentAsInt(); break; case "pollingIntervalSeconds": result.QueuePollingInterval = TimeSpan.FromSeconds(reader.ReadElementContentAsInt()); break; case "pollingIntervalThrottledSeconds": result.QueuePollingIntervalThrottled = TimeSpan.FromSeconds(reader.ReadElementContentAsInt()); break; case "maxRetries": result.MaxRetries = reader.ReadElementContentAsInt(); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); break; case "Session": if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "maxSessionLogs": result.MaxSessionLogs = reader.ReadElementContentAsInt(); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); break; case "MappingRules": if (!reader.IsEmptyElement) result.MappingRules = MappingRules.Load(reader); else reader.Skip(); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else reader.Skip(); return result; }