本文整理汇总了C#中System.Xml.XmlTextReader.MoveToAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextReader.MoveToAttribute方法的具体用法?C# System.Xml.XmlTextReader.MoveToAttribute怎么用?C# System.Xml.XmlTextReader.MoveToAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了System.Xml.XmlTextReader.MoveToAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read_Configuration_File
/// <summary> Reads the inficated configuration file </summary>
/// <param name="ConfigFile"> Configuration file to read </param>
/// <exception>File is checked for existence first, otherwise all encountered exceptions will be thrown</exception>
public static void Read_Configuration_File(string ConfigFile)
{
if (!File.Exists(ConfigFile))
return;
databaseInfo.Clear();
StreamReader reader = new StreamReader(ConfigFile);
System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(reader);
while (xmlReader.Read())
{
if (xmlReader.NodeType == System.Xml.XmlNodeType.Element)
{
string node_name = xmlReader.Name.ToLower();
switch (node_name)
{
case "connection_string":
Database_Instance_Configuration newDb = new Database_Instance_Configuration();
if (xmlReader.MoveToAttribute("type"))
{
if (xmlReader.Value.ToLower() == "postgresql")
newDb.Database_Type = SobekCM_Database_Type_Enum.PostgreSQL;
}
if (xmlReader.MoveToAttribute("active"))
{
if (xmlReader.Value.ToLower() == "false")
newDb.Is_Active = false;
}
if (xmlReader.MoveToAttribute("canAbort"))
{
if (xmlReader.Value.ToLower() == "false")
newDb.Can_Abort = false;
}
if (xmlReader.MoveToAttribute("isHosted"))
{
if (xmlReader.Value.ToLower() == "true")
isHosted = true;
}
if (xmlReader.MoveToAttribute("name"))
newDb.Name = xmlReader.Value.Trim();
xmlReader.Read();
newDb.Connection_String = xmlReader.Value;
if (newDb.Name.Length == 0)
newDb.Name = "Connection" + (databaseInfo.Count + 1);
databaseInfo.Add(newDb);
break;
case "erroremails":
xmlReader.Read();
systemErrorEmail = xmlReader.Value;
break;
case "errorpage":
xmlReader.Read();
System_Error_URL = xmlReader.Value;
break;
case "ghostscript_executable":
xmlReader.Read();
ghostscriptExecutable = xmlReader.Value;
break;
case "imagemagick_executable":
xmlReader.Read();
imageMagickExecutable = xmlReader.Value;
break;
case "pause_between_polls":
xmlReader.Read();
int testValue;
if (Int32.TryParse(xmlReader.Value, out testValue))
Builder_Override_Seconds_Between_Polls = testValue;
break;
case "publish_logs_directory":
xmlReader.Read();
Builder_Logs_Publish_Directory = xmlReader.Value;
break;
}
}
}
xmlReader.Close();
reader.Close();
}
示例2: GetBasic
/// <summary>
/// Gets basic event information.
/// </summary>
/// <param name="log">The event's log.</param>
/// <param name="source">The event's source. Can be <c>null</c>.</param>
/// <param name="eventId">The event's id. Can be <c>null</c>.</param>
/// <returns><c>true</c> if subscription represents a basic event, <c>false</c> if not.</returns>
public bool GetBasic(out string log, out string source, out int? eventId)
{
log = source = null;
eventId = null;
if (!string.IsNullOrEmpty(this.Subscription))
{
using (System.IO.MemoryStream str = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(this.Subscription)))
{
using (System.Xml.XmlTextReader rdr = new System.Xml.XmlTextReader(str))
{
rdr.MoveToContent();
rdr.ReadStartElement("QueryList");
if (rdr.Name == "Query" && rdr.MoveToAttribute("Path"))
{
string path = rdr.Value;
if (rdr.MoveToElement() && rdr.ReadToDescendant("Select") && path.Equals(rdr["Path"], StringComparison.InvariantCultureIgnoreCase))
{
string content = rdr.ReadString();
System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(content,
@"\*(?:\[System\[(?:Provider\[\@Name='(?<s>[^']+)'\])?(?:\s+and\s+)?(?:EventID=(?<e>\d+))?\]\])",
System.Text.RegularExpressions.RegexOptions.IgnoreCase |
System.Text.RegularExpressions.RegexOptions.Compiled |
System.Text.RegularExpressions.RegexOptions.Singleline |
System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace);
if (m.Success)
{
log = path;
if (m.Groups["s"].Success)
source = m.Groups["s"].Value;
if (m.Groups["e"].Success)
eventId = Convert.ToInt32(m.Groups["e"].Value);
return true;
}
}
}
}
}
}
return false;
}
示例3: Read_Configuration_File
private void Read_Configuration_File(string config_file)
{
System.IO.StreamReader reader = new System.IO.StreamReader(config_file);
System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(reader);
while (xmlReader.Read())
{
if (xmlReader.NodeType == System.Xml.XmlNodeType.Element)
{
string node_name = xmlReader.Name.ToLower();
switch (node_name)
{
case "connection_string":
if (xmlReader.MoveToAttribute("type"))
{
db_type = xmlReader.Value.ToString();
}
xmlReader.Read();
connection_string = xmlReader.Value;
break;
case "error_emails":
xmlReader.Read();
error_emails = xmlReader.Value;
break;
case "error_page":
xmlReader.Read();
error_page = xmlReader.Value;
break;
case "ghostscript_executable":
xmlReader.Read();
ghostscript = xmlReader.Value;
break;
case "imagemagick_executable":
xmlReader.Read();
imagemagick = xmlReader.Value;
break;
}
}
}
xmlReader.Close();
reader.Close();
}
示例4: Read_Configuration_File
public static void Read_Configuration_File( string config_file )
{
if (!File.Exists(config_file))
return;
System.IO.StreamReader reader = new System.IO.StreamReader(config_file);
System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(reader);
while (xmlReader.Read())
{
if (xmlReader.NodeType == System.Xml.XmlNodeType.Element)
{
string node_name = xmlReader.Name.ToLower();
switch (node_name)
{
case "connection_string":
if (xmlReader.MoveToAttribute("type"))
{
if (xmlReader.Value.ToString().ToLower() == "postgresql")
sobekDatabaseType = SobekCM_Database_Type_Enum.PostgreSQL;
}
xmlReader.Read();
Database_Connection_String = xmlReader.Value;
break;
case "error_emails":
xmlReader.Read();
systemErrorEmail = xmlReader.Value;
break;
case "error_page":
xmlReader.Read();
System_Error_URL = xmlReader.Value;
break;
case "ghostscript_executable":
xmlReader.Read();
ghostscriptExecutable = xmlReader.Value;
break;
case "imagemagick_executable":
xmlReader.Read();
imageMagickExecutable = xmlReader.Value;
break;
}
}
}
xmlReader.Close();
reader.Close();
}