/// <summary> /// </summary> /// <param name="settings"> </param> /// <exception cref="WebException"></exception> /// <returns> </returns> public virtual XmlReader LoadContentFromXml(XmlReaderSettings settings) { var i = 0; if (string.IsNullOrEmpty(ContentLocation)) { throw new InvalidOperationException("Property ContentLocation must be set prior to retrieving channels."); } var transforms = new ChannelTransforms(); try { if (IsNetworkAvailable) { return(transforms.TransformContent(XmlReader.Create(ContentLocation, settings))); } i++; throw new WebException(Resources.Properties.Resources.NetworkConnectionError , WebExceptionStatus.ConnectFailure); } // poor style, but these are recoverable exceptions. only throw after reattempting method call 3 times catch (XmlException exc) { Trace.WriteLine(string.Format("{0} {1} occurred in {2}", exc.GetType(), exc.Message, GetType()), TraceCategory.Exception.ToString()); if (i <= 3) { Trace.WriteLine( string.Format("Attempt #{0} for loading {1}", i.ToString(CultureInfo.InvariantCulture), ContentLocation), TraceCategory.Exception.ToString()); return(LoadContentFromXml(settings)); } throw; } catch (Exception exc) { Trace.WriteLine(string.Format("{0} {1} occurred in {2}", exc.GetType(), exc.Message, GetType()), TraceCategory.Exception.ToString()); if (i <= 3) { Trace.WriteLine( string.Format("Attempt #{0} for loading {1}", i.ToString(CultureInfo.InvariantCulture), ContentLocation), TraceCategory.Exception.ToString()); return(LoadContentFromXml(settings)); } throw; } }
protected internal XmlReader LoadXmlData() { _readerSettings = new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = true, DtdProcessing = DtdProcessing.Prohibit }; // EDGE CASE PROCESSING GOES HERE var transform = new ChannelTransforms(); if (IsNetworkAvailable) { return (transform.TransformContent(XmlReader.Create(C.Settings.Default.DIPlaylistXml, _readerSettings))); } throw new WebException(Resources.Properties.Resources.NetworkConnectionError , WebExceptionStatus.ConnectFailure); }