/// <summary> /// Attempts to read the string for the specified value. This will first test to see if the /// attribute exists and encloses the test in a try block. If it fails or the node does not /// exist, the default value is returned. /// </summary> /// <param name="attribute">The string name for the attribute to read from the CurrentElement.</param> /// <returns>A string specifying the value.</returns> /// <exception cref="TryXmlDocumentException">CurrentElement Not Specified.</exception> public string ReadText(string attribute) { if (CurrentElement == null) { throw new TryXmlDocumentException(DataFormsMessageStrings.CurrentElementNotSpecified); } string result = string.Empty; try { if (CurrentElement.HasAttribute(attribute)) { result = CurrentElement.GetAttribute(attribute); } } catch { } return(result); }
/// <summary> /// Attempts to read the integer value from the specified attribute, translating it from /// a text equivalent via parsing. /// </summary> /// <param name="attribute">The string name of the attribute to read from the CurrentElement.</param> /// <returns>An integer parsed from the inner text of the specified attribute on the CurrentElement.</returns> /// <exception cref="TryXmlDocumentException">CurrentElement Not Specified.</exception> public int ReadInteger(string attribute) { if (CurrentElement == null) { throw new TryXmlDocumentException(DataFormsMessageStrings.CurrentElementNotSpecified); } int result = 0; try { if (CurrentElement.HasAttribute(attribute)) { result = int.Parse(CurrentElement.GetAttribute(attribute)); } } catch { } return(result); }
/// <summary> /// Attempts to read the double value from the specified attribute, translating it from /// a text equivalent via parsing. /// </summary> /// <param name="attribute">The string name of the attribute to read from the CurrentElement.</param> /// <returns>A double value parsed from the inner text of the specified attribute on the CurrentElement.</returns> /// <exception cref="TryXmlDocumentException">CurrentElement Not Specified.</exception> public double ReadDouble(string attribute) { if (CurrentElement == null) { throw new TryXmlDocumentException(DataFormsMessageStrings.CurrentElementNotSpecified); } double result = 0.0; try { if (CurrentElement.HasAttribute(attribute)) { result = double.Parse(CurrentElement.GetAttribute(attribute)); } } catch { } return(result); }
/// <summary> /// Attempts to read the boolean value from the specified attribute, translating it from a text equivalent. /// </summary> /// <param name="attribute">The string name of the attribute to read from the CurrentElement.</param> /// <returns>A boolean value based on parsing the text.</returns> /// <exception cref="TryXmlDocumentException">CurrentElement Not Specified.</exception> public bool ReadBool(string attribute) { if (CurrentElement == null) { throw new TryXmlDocumentException(DataFormsMessageStrings.CurrentElementNotSpecified); } bool result = false; try { if (CurrentElement.HasAttribute(attribute)) { result = bool.Parse(CurrentElement.GetAttribute(attribute)); } } catch { } return(result); }
/// <summary> /// Attempts to read the color from a text representation of an argb integer value. /// </summary> /// <param name="attribute">The name of the attribute to read from the CurrentElement.</param> /// <returns>A Color structure.</returns> /// <exception cref="TryXmlDocumentException">CurrentElement Not Specified.</exception> public Color ReadColor(string attribute) { if (CurrentElement == null) { throw new TryXmlDocumentException(DataFormsMessageStrings.CurrentElementNotSpecified); } Color result = Color.Empty; try { if (CurrentElement.HasAttribute(attribute)) { string txtCol = CurrentElement.GetAttribute(attribute); result = Color.FromArgb(int.Parse(txtCol)); } } catch { } return(result); }