本文整理汇总了C#中System.Xml.XmlTextReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextReader.Close方法的具体用法?C# System.Xml.XmlTextReader.Close怎么用?C# System.Xml.XmlTextReader.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了System.Xml.XmlTextReader.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadHighlightingDefinition
private void LoadHighlightingDefinition()
{
var xshdUri = App.GetResourceUri("simai.xshd");
var rs = Application.GetResourceStream(xshdUri);
var reader = new System.Xml.XmlTextReader(rs.Stream);
definition = HighlightingLoader.Load(reader, HighlightingManager.Instance);
reader.Close();
}
示例2: GetSummary
/// <summary>
/// Currently a naive implementation. Treats all fields under summary as text.
/// </summary>
/// <param name="xmlDocumentation"></param>
/// <returns></returns>
public string GetSummary(string xmlDocumentation)
{
var frag = new System.Xml.XmlTextReader(xmlDocumentation, System.Xml.XmlNodeType.Element, null);
string result = "";
while (frag.Read()) {
result += frag.Value;
}
frag.Close();
return result;
}
示例3: ReadSettings
/// <summary>
/// loads a configuration from a xml-file - if there isn't one, use default settings
/// </summary>
public void ReadSettings()
{
bool dirty = false;
Reset();
try
{
System.Xml.XmlTextReader xmlConfigReader = new System.Xml.XmlTextReader("settings.xml");
while (xmlConfigReader.Read())
{
if (xmlConfigReader.NodeType == System.Xml.XmlNodeType.Element)
{
switch (xmlConfigReader.Name)
{
case "display":
fullscreen = Convert.ToBoolean(xmlConfigReader.GetAttribute("fullscreen"));
resolutionX = Convert.ToInt32(xmlConfigReader.GetAttribute("resolutionX"));
resolutionY = Convert.ToInt32(xmlConfigReader.GetAttribute("resolutionY"));
// validate resolution
// TODO
/* if (!GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Any(x => x.Format == SurfaceFormat.Color &&
x.Height == resolutionY && x.Width == resolutionX))
{
ChooseStandardResolution();
dirty = true;
} */
break;
}
}
}
xmlConfigReader.Close();
}
catch
{
// error in xml document - write a new one with standard values
try
{
Reset();
dirty = true;
}
catch
{
}
}
// override fullscreen resolutions
if (fullscreen)
{
ResolutionX = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
ResolutionY = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
}
if(dirty)
Save();
}
示例4: Unmarshall
public override WebServiceResponse Unmarshall(XmlUnmarshallerContext context)
{
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(context.ResponseStream);
Message message = new Message();
while (reader.Read())
{
switch (reader.NodeType)
{
case System.Xml.XmlNodeType.Element:
switch (reader.LocalName)
{
case MNSConstants.XML_ELEMENT_MESSAGE_ID:
message.Id = reader.ReadElementContentAsString();
break;
case MNSConstants.XML_ELEMENT_RECEIPT_HANDLE:
message.ReceiptHandle = reader.ReadElementContentAsString();
break;
case MNSConstants.XML_ELEMENT_MESSAGE_BODY_MD5:
message.BodyMD5 = reader.ReadElementContentAsString();
break;
case MNSConstants.XML_ELEMENT_MESSAGE_BODY:
message.Body = reader.ReadElementContentAsString();
break;
case MNSConstants.XML_ELEMENT_ENQUEUE_TIME:
message.EnqueueTime = AliyunSDKUtils.ConvertFromUnixEpochSeconds(reader.ReadElementContentAsLong());
break;
case MNSConstants.XML_ELEMENT_NEXT_VISIBLE_TIME:
message.NextVisibleTime = AliyunSDKUtils.ConvertFromUnixEpochSeconds(reader.ReadElementContentAsLong());
break;
case MNSConstants.XML_ELEMENT_FIRST_DEQUEUE_TIME:
message.FirstDequeueTime = AliyunSDKUtils.ConvertFromUnixEpochSeconds(reader.ReadElementContentAsLong());
break;
case MNSConstants.XML_ELEMENT_DEQUEUE_COUNT:
message.DequeueCount = (uint)reader.ReadElementContentAsInt();
break;
case MNSConstants.XML_ELEMENT_PRIORITY:
message.Priority = (uint)reader.ReadElementContentAsInt();
break;
}
break;
}
}
reader.Close();
return new ReceiveMessageResponse()
{
Message = message
};
}
示例5: GetReport
public static System.Xml.XmlDocument GetReport(string reportName)
{
// http://blogs.msdn.com/b/tolong/archive/2007/11/15/read-write-xml-in-memory-stream.aspx
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
// doc.Load(memorystream);
// doc.Load(FILE_NAME);
// doc.Load(strFileName);
using (System.IO.Stream strm = GetEmbeddedReport(reportName))
{
using (System.Xml.XmlTextReader xtrReader = new System.Xml.XmlTextReader(strm))
{
doc.Load(xtrReader);
xtrReader.Close();
} // End Using xtrReader
} // End Using strm
return doc;
}
示例6: VerifyAdwaysAccount
private string VerifyAdwaysAccount(string CustomerID, string AdwaysID, string AdwaysEmail)
{
try
{
string url = "http://club.pchome.net/union/icson/checkHashCode.php?code=" + txtPPCode.Text.Trim();
System.Net.WebClient wc = new System.Net.WebClient();
System.IO.Stream stream = wc.OpenRead(url);
System.Xml.XmlReader xmlread = new System.Xml.XmlTextReader(stream);
string ppResult = stream.ToString();
stream.Close();
wc.Dispose();
while (xmlread.Read())
{
if (xmlread.Name.ToUpper().Equals("RESULT"))
{
break;
}
}
string result = xmlread.GetAttribute(0).ToString();
xmlread.Close();
return result;
}
catch
{
return "-1";
}
}
示例7: FromXml
public static void FromXml (System.IO.Stream stream, PackageMatchDelegate callback)
{
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader (stream);
FromXml (reader, callback);
reader.Close ();
stream.Close ();
}
示例8: 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();
}
示例9: listMetadataFormats
public ListMetadataFormats listMetadataFormats(string sidentifier)
{
System.IO.Stream objStream;
ListMetadataFormats objFormat = new ListMetadataFormats();
System.Net.HttpWebRequest wr;
System.Xml.XmlTextReader rd;
if (sidentifier.Length == 0)
{
prequestURL = baseURL + "?verb=ListMetadataFormats";
}
else
{
prequestURL = baseURL + "?verb=ListMetadataFormats&identifier=" + sidentifier;
}
try
{
wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
wr.UserAgent = cUserAgent;
System.Net.WebResponse response = wr.GetResponse();
objStream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
prawXML = reader.ReadToEnd();
reader.Close();
rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
}
catch (Exception e)
{
error.errorName = e.ToString();
error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
return null;
}
while (rd.Read())
{
if (rd.NodeType == System.Xml.XmlNodeType.Element)
{
if (rd.Name == "responseDate")
{
presponseDate = rd.ReadString();
}
else if (rd.Name == "ListMetadataFormats")
{
while (rd.Read()) // && rd.NodeType != System.Xml.XmlNodeType.EndElement)
{
switch (rd.Name)
{
case "metadataPrefix":
objFormat.metadataPrefix.Add(ParseOAI(ref rd, "metadataPrefix"));
break;
case "schema":
objFormat.schema.Add(ParseOAI(ref rd, "schema"));
break;
case "metadataNamespace":
objFormat.metadataNamespace.Add(ParseOAI(ref rd, "metadataNamespace"));
break;
default:
break;
}
}
}
else if (rd.Name == "error")
{
error.errorName = rd.GetAttribute("code");
error.errorDescription = rd.ReadString();
return null;
}
}
}
rd.Close();
return objFormat;
}
示例10: identify
//=======================================================================
// Sub/Function: identify
// Description: Use this function to return the identifier information
// from an OAI repository.
//
// example:
// OAI objOAI = new OAI("http://memory.loc.gov/cgi-bin/oai2_0");
// Identify objID = new Identify();
//
// objID = objOAI.identify();
// Console.WriteLine("Base URL: " + objID.baseURL);
// Console.WriteLine("Repository: " + objID.repositoryName);
// Console.WriteLine("Deleted Records: " + objID.deletedRecord);
//=======================================================================
public Identify identify()
{
System.IO.Stream objStream;
Identify objID = new Identify();
System.Net.HttpWebRequest wr;
System.Xml.XmlTextReader rd;
try
{
prequestURL = baseURL + "?verb=Identify";
wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
wr.UserAgent = cUserAgent;
System.Net.WebResponse response = wr.GetResponse();
objStream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
prawXML = reader.ReadToEnd();
reader.Close();
rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
}
catch (Exception e)
{
error.errorName = e.ToString();
error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
return null;
}
while (rd.Read())
{
if (rd.NodeType == System.Xml.XmlNodeType.Element)
{
if (rd.Name == "responseDate")
{
presponseDate = rd.ReadString();
}
else if (rd.Name == "Identify")
{
while (rd.Read() && rd.NodeType != System.Xml.XmlNodeType.EndElement)
{
switch (rd.Name)
{
case "repositoryName":
objID.repositoryName = ParseOAI(ref rd, "repositoryName");
break;
case "baseURL":
objID.baseURL = ParseOAI(ref rd, "baseURL");
break;
case "protocolVersion":
objID.protocolVersion = ParseOAI(ref rd, "protocolVersion");
break;
case "earliestDatestamp":
objID.earliestDatestamp = ParseOAI(ref rd, "earliestDatestamp");
break;
case "deletedRecord":
objID.deletedRecord = ParseOAI(ref rd, "deletedRecord");
break;
case "granularity":
objID.granularity = ParseOAI(ref rd, "granularity");
break;
case "adminEmail":
objID.adminEmail.Add(ParseOAI(ref rd, "adminEmail"));
break;
case "compression":
objID.compression.Add(ParseOAI(ref rd, "compression"));
break;
case "description":
objID.description.Add(ParseOAIContainer(ref rd, "description"));
break;
}
}
}
else if (rd.Name == "error")
{
error.errorName = rd.GetAttribute("code");
error.errorDescription = rd.ReadString();
return null;
}
}
}
rd.Close();
return objID;
}
示例11: Get_Definephrase
public static string Get_Definephrase(string tag)
{
try
{
string ffile = "/cmm/xhtml/Definephrase.xml";
string fpath = HttpContext.Current.Server.MapPath(ffile);
if (!System.IO.File.Exists(fpath)) return "";
string vlreturn = "";
System.Xml.XmlTextReader rdr = new System.Xml.XmlTextReader(fpath);
while (rdr.Read())
{
switch (rdr.NodeType)
{
case System.Xml.XmlNodeType.Element:
if (rdr.Name == LANG + tag)
{
vlreturn = rdr.ReadElementString();
goto lexit;
}
else if (rdr.Name != "phrase")
rdr.Skip();
break;
default:
break;
}
}
lexit:
rdr.Close();
return vlreturn;
}
catch
{
return "Cannot get phrase";
}
}
示例12: LoadExample
/// <summary>
/// Load embedded example
/// </summary>
/// <param name="name">Example file name</param>
public void LoadExample(string name)
{
try
{
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(_model.GetType());
using (System.Xml.XmlReader reader = new System.Xml.XmlTextReader(System.Windows.Application.GetResourceStream(new System.Uri("/examples/" + name, UriKind.Relative)).Stream))
{
if (x.CanDeserialize(reader))
_model = x.Deserialize(reader) as SettingsModel;
reader.Close();
}
// update all properties
InvokePropertyChanged(null);
}
catch
{
System.Windows.MessageBox.Show("Couldn't load L-System, please try again later.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
}
}
示例13: LoadDefinition
/// <summary>
/// Load L-System definition file
/// </summary>
public void LoadDefinition()
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".ls"; // Default file extension
dlg.Filter = "L-System files(*.ls)|*.ls|All files (*.*)|*.*"; // Filter files by extension
// Show save file dialog box
bool? result = dlg.ShowDialog();
// Process save file dialog box results
if (result == true)
{
// Load document
string filename = dlg.FileName;
try
{
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(_model.GetType());
using (System.Xml.XmlReader reader = new System.Xml.XmlTextReader(filename))
{
if (x.CanDeserialize(reader))
_model = x.Deserialize(reader) as SettingsModel;
reader.Close();
}
}
catch
{
System.Windows.MessageBox.Show("Couldn't load L-System, please try again later.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
}
}
// update all properties
InvokePropertyChanged(null);
}
示例14: IsMediumTrustSetInConfig
//Method two: Get is medium trust (get if config is set as medium trust)
private static bool IsMediumTrustSetInConfig()
{
bool result = false;
try
{
string webConfigFile = System.IO.Path.Combine(System.Web.HttpContext.Current.Request.PhysicalApplicationPath, "web.config");
System.Xml.XmlTextReader webConfigReader = new System.Xml.XmlTextReader(new System.IO.StreamReader(webConfigFile));
webConfigReader.ReadToFollowing("trust");
result = webConfigReader.GetAttribute("level") == "Medium";
webConfigReader.Close(); //Close before return
return result;
}
catch
{
return result;
}
}
示例15: ReadConfig
// Lecture de la configuration
static void ReadConfig()
{
string config_file = "config.xml";
if (!System.IO.File.Exists(config_file))
{
var newconf = new System.Xml.XmlTextWriter(config_file, null);
newconf.WriteStartDocument();
newconf.WriteStartElement("config");
newconf.WriteElementString("last_update", "0");
newconf.WriteElementString("auth_token", "");
newconf.WriteEndElement();
newconf.WriteEndDocument();
newconf.Close();
}
var conf = new System.Xml.XmlTextReader(config_file);
string CurrentElement = "";
while (conf.Read())
{
switch(conf.NodeType) {
case System.Xml.XmlNodeType.Element:
CurrentElement = conf.Name;
break;
case System.Xml.XmlNodeType.Text:
if (CurrentElement == "last_update")
LastUpdate = DateTime.Parse(conf.Value);
if (CurrentElement == "auth_token")
AuthToken = conf.Value;
break;
}
}
conf.Close();
// On vérifie que le token est encore valide
if (AuthToken.Length > 0)
{
var flickr = new Flickr(Program.ApiKey, Program.SharedSecret);
try
{
Auth auth = flickr.AuthCheckToken(AuthToken);
Username = auth.User.UserName;
}
catch (FlickrApiException ex)
{
//MessageBox.Show(ex.Message, "Authentification requise",
// MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
AuthToken = "";
}
}
}