public static string ReadMicroMessages(MicroMessages messageId) { string MicroMessageText = string.Empty; string DocumentURL = XMLIntegration.ReadMicroMessages().BaseURI; XmlTextReader DocumentReader = new XmlTextReader(DocumentURL); DocumentReader.WhitespaceHandling = WhitespaceHandling.None; while (DocumentReader.Read()) { if (string.IsNullOrEmpty(MicroMessageText)) { if (DocumentReader.NodeType.Equals(XmlNodeType.Element)) { while (DocumentReader.MoveToNextAttribute()) { if (DocumentReader.Value.Equals(messageId.ToString())) { DocumentReader.MoveToAttribute("Text"); MicroMessageText = DocumentReader.Value.ToString(); break; } } } } else { break; } } return(MicroMessageText); }
/// <summary> /// Saves the integrator. /// </summary> /// <param name="toSave">The integrator to save</param> /// <remarks></remarks> public virtual void save(Integrator toSave) { if (!object.ReferenceEquals(null, toSave)) { var ndat = ""; var xf = new XmlSerializer(typeof(XMLIntegration)); var ms = new MemoryStream(); var sr = new StreamReader(ms); var sw = new StreamWriter(ms); try { var xtodo = new XMLIntegration(toSave); xf.Serialize(sw, xtodo); ms.Position = 0; ndat = sr.ReadToEnd(); } catch (ObjectDisposedException e) { ndat = ""; sr.Dispose(); sr = null; sw.Dispose(); sw = null; ms.Dispose(); ms = null; xf = null; throw e; } catch (IOException e) { ndat = ""; sr.Dispose(); sr = null; sw.Dispose(); sw = null; ms.Dispose(); ms = null; xf = null; throw e; } catch (OutOfMemoryException e) { ndat = ""; sr.Dispose(); sr = null; sw.Dispose(); sw = null; ms.Dispose(); ms = null; xf = null; throw e; } finally { if (!object.ReferenceEquals(null, sr)) { sr.Dispose(); sr = null; } if (!object.ReferenceEquals(null, sw)) { sw.Dispose(); sw = null; } if (!object.ReferenceEquals(null, ms)) { ms.Dispose(); ms = null; } xf = null; } _data = ndat; } else { throw new ArgumentNullException("toSave"); } }
/// <summary> /// Loads the integrator. /// </summary> /// <returns>Integrator</returns> /// <remarks></remarks> public virtual Integrator load() { if (object.ReferenceEquals(null, _data)) { throw new NullReferenceException("_data"); } Integrator toret = null; var xf = new XmlSerializer(typeof(XMLIntegration)); var ms = new MemoryStream(); var sw = new StreamWriter(ms); try { XMLIntegration xtoret = null; sw.AutoFlush = true; for (int i = 0; i < _data.Length; i++) { sw.Write(_data[i]); } if (!sw.AutoFlush) { sw.Flush(); } sw.AutoFlush = false; ms.Position = 0; xtoret = xf.Deserialize(ms) as XMLIntegration; toret = !object.ReferenceEquals(null, xtoret) ? xtoret.toIntegrator() : null; } catch (System.Text.EncoderFallbackException e) { toret = null; sw.Dispose(); sw = null; ms.Dispose(); ms = null; xf = null; throw e; } catch (ObjectDisposedException e) { toret = null; sw.Dispose(); sw = null; ms.Dispose(); ms = null; xf = null; throw e; } catch (IOException e) { toret = null; sw.Dispose(); sw = null; ms.Dispose(); ms = null; xf = null; throw e; } catch (NotSupportedException e) { toret = null; sw.Dispose(); sw = null; ms.Dispose(); ms = null; xf = null; throw e; } finally { if (!object.ReferenceEquals(null, sw)) { sw.Dispose(); sw = null; } if (!object.ReferenceEquals(null, ms)) { ms.Dispose(); ms = null; } xf = null; } return(toret); }