using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Reflection; namespace CloseIssueConsole { public class ReadWriteXML { public string _jiraURL; public string JiraURL() { if (_jiraURL == null) { string filePath = Assembly.GetCallingAssembly().Location; string sStartupPath = System.IO.Path.GetDirectoryName(filePath); using (XmlTextReader objXmlTextReader = new XmlTextReader(sStartupPath + @"\Config.xml")) { string sName = ""; while (objXmlTextReader.Read()) { switch (objXmlTextReader.NodeType) { case XmlNodeType.Element: sName = objXmlTextReader.Name; break; case XmlNodeType.Text: switch (sName) { case "jiraURL": _jiraURL = objXmlTextReader.Value; break; } break; } } } } return _jiraURL; } public string _jirausername; public string Jirausername() { if (_jirausername == null) { string filePath = Assembly.GetCallingAssembly().Location; string sStartupPath = System.IO.Path.GetDirectoryName(filePath); using (XmlTextReader objXmlTextReader = new XmlTextReader(sStartupPath + @"\Config.xml")) { string sName = ""; while (objXmlTextReader.Read()) { switch (objXmlTextReader.NodeType) { case XmlNodeType.Element: sName = objXmlTextReader.Name; break; case XmlNodeType.Text: switch (sName) { case "username": _jirausername = objXmlTextReader.Value; break; } break; } } } } return _jirausername; }// public string _jiraPassword; public string JiraPassword() { if (_jiraPassword == null) { string filePath = Assembly.GetCallingAssembly().Location; string sStartupPath = System.IO.Path.GetDirectoryName(filePath); using (XmlTextReader objXmlTextReader = new XmlTextReader(sStartupPath + @"\Config.xml")) { string sName = ""; while (objXmlTextReader.Read()) { switch (objXmlTextReader.NodeType) { case XmlNodeType.Element: sName = objXmlTextReader.Name; break; case XmlNodeType.Text: switch (sName) { case "password": _jiraPassword = objXmlTextReader.Value; break; } break; } } } } return _jiraPassword; } public string _jiraDefaultFilter; public string JiraDefaultFilter() { if (_jiraDefaultFilter == null) { string filePath = Assembly.GetCallingAssembly().Location; string sStartupPath = System.IO.Path.GetDirectoryName(filePath); using (XmlTextReader objXmlTextReader = new XmlTextReader(sStartupPath + @"\Config.xml")) { string sName = ""; while (objXmlTextReader.Read()) { switch (objXmlTextReader.NodeType) { case XmlNodeType.Element: sName = objXmlTextReader.Name; break; case XmlNodeType.Text: switch (sName) { case "defaultFilter": _jiraDefaultFilter = objXmlTextReader.Value; break; } break; } } } } return _jiraDefaultFilter; } public void WriteXMLFile() { try { string filePath = Assembly.GetCallingAssembly().Location; string sStartupPath = System.IO.Path.GetDirectoryName(filePath); using (XmlTextWriter objXmlTextWriter = new XmlTextWriter(sStartupPath + @"\Config.xml", null)) { objXmlTextWriter.Formatting = Formatting.Indented; objXmlTextWriter.WriteStartDocument(); objXmlTextWriter.WriteStartElement("settings"); objXmlTextWriter.WriteStartElement("jiraURL"); objXmlTextWriter.WriteString(_jiraURL); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.WriteStartElement("username"); objXmlTextWriter.WriteString(_jirausername); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.WriteStartElement("password"); objXmlTextWriter.WriteString(_jiraPassword); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.WriteStartElement("defaultFilter"); objXmlTextWriter.WriteString(_jiraDefaultFilter); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.WriteEndDocument(); objXmlTextWriter.Flush(); objXmlTextWriter.Close(); } } catch (Exception ex) { throw ex; } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)