本文整理汇总了C#中XmlTextReader.ReadElementContentAsDouble方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextReader.ReadElementContentAsDouble方法的具体用法?C# XmlTextReader.ReadElementContentAsDouble怎么用?C# XmlTextReader.ReadElementContentAsDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadElementContentAsDouble方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadConfigFile
void LoadConfigFile()
{
try
{
XmlTextReader doc = new XmlTextReader("reddit_api.xml");
while (doc.Read())
{
if (doc.NodeType == XmlNodeType.Element)
{
switch (doc.Name)
{
case "seconds_between_api_calls":
m_seconds_between_calls = doc.ReadElementContentAsDouble();
break;
case "seconds_before_cache_invalid":
m_seconds_before_cache_invalid = doc.ReadElementContentAsDouble();
break;
case "default_content_limit":
m_content_limit = doc.ReadElementContentAsInt();
break;
case "object_mappings":
string kind = "", objectname = "";
while (doc.MoveToNextAttribute())
{
if (doc.Name == "kind")
{
kind = doc.Value;
}
else if (doc.Name == "object")
{
objectname = doc.Value;
}
}
if (m_object_mapping.ContainsKey(kind))
m_object_mapping["kind"] = objectname;
else
m_object_mapping.Add(kind, objectname);
break;
case "domain":
m_domain = doc.ReadElementContentAsString();
break;
}
}
}
doc.Close();
}
catch (FileNotFoundException)
{
StreamWriter s = new StreamWriter("reddit_api.xml");
s.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
s.WriteLine("<reddit_api_config>");
s.WriteLine("<seconds_between_api_calls>2</seconds_between_api_calls>" );
s.WriteLine("<seconds_before_cache_invalid>30</seconds_before_cache_invalid>");
s.WriteLine("<default_content_limit>25</default_content_limit>");
s.WriteLine("<object_mappings kind=\"comment_kind\" object=\"t1\"/>");
s.WriteLine("<object_mappings kind=\"message_kind\" object=\"t4\"/>");
s.WriteLine("<object_mappings kind=\"more_kind\" object =\"more\"/>");
s.WriteLine("<object_mappings kind=\"redditor_kind\" object=\"t2\"/>");
s.WriteLine("<object_mappings kind=\"submission_kind\" object=\"t3\"/>");
s.WriteLine("<object_mappings kind=\"subreddit_kind\" object=\"t5\"/>");
s.WriteLine("<object_mappings kind=\"userlist_kind\" object=\"UserList\"/>");
s.WriteLine("<domain>http://www.reddit.com/</domain>");
s.WriteLine("<!--");
s.WriteLine("message_kind: t7");
s.WriteLine("submission_kind: t6");
s.WriteLine("subreddit_kind: t5");
s.WriteLine(" -->");
s.WriteLine("</reddit_api_config>");
s.Close();
LoadConfigFile();
}
}