本文整理汇总了C#中System.IO.StringReader.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StringReader.Dispose方法的具体用法?C# System.IO.StringReader.Dispose怎么用?C# System.IO.StringReader.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringReader
的用法示例。
在下文中一共展示了System.IO.StringReader.Dispose方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromXmlString
public virtual bool FromXmlString(string x)
{
System.IO.StringReader sw = new System.IO.StringReader(x);
XmlReader xr = XmlReader.Create(sw);
bool result = FromXml(ref xr);
sw.Dispose();
xr.Close();
return result;
}
示例2: Deserialize
public static VAST Deserialize(string xml)
{
//for now hack out the extensions - we aren't using them, and the parser doesn't like them.
xml = xml.SectionsReplace("<Extensions>", "</Extensions>", "");
System.IO.StringReader stringReader = null;
try
{
stringReader = new System.IO.StringReader(xml);
return ((VAST)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
}
finally
{
if ((stringReader != null))
{
stringReader.Dispose();
}
}
}
示例3: TransformXml
public static string TransformXml(System.Xml.XmlDocument Document, string XslPath)
{
XslCompiledTransform xTrans = null;
#region Do the transform
try
{
bool debugmode = false;
#if DEBUG
debugmode = true;
#endif
xTrans = new XslCompiledTransform(debugmode);
xTrans.Load(XslPath);
}
catch (Exception ex)
{
throw new Exception("Could not load XSL Transform", ex);
}
string results = "";
try
{
System.IO.StringReader SR = new System.IO.StringReader(Document.OuterXml);
System.Xml.XmlReaderSettings xReadSettings = new System.Xml.XmlReaderSettings();
xReadSettings.CloseInput = true;
xReadSettings.ConformanceLevel = System.Xml.ConformanceLevel.Fragment;
xReadSettings.IgnoreComments = true;
xReadSettings.IgnoreWhitespace = true;
System.Xml.XmlReader xReader = System.Xml.XmlReader.Create(SR, xReadSettings);
StringBuilder SB = new StringBuilder();
System.IO.StringWriter SW = new System.IO.StringWriter(SB);
System.Xml.XmlWriterSettings xWriteSettings = new System.Xml.XmlWriterSettings();
xWriteSettings.CloseOutput = true;
xWriteSettings.Indent = false;
xWriteSettings.NewLineOnAttributes = false;
xWriteSettings.ConformanceLevel = System.Xml.ConformanceLevel.Fragment;
System.Xml.XmlWriter xWriter = System.Xml.XmlWriter.Create(SW, xWriteSettings);
xTrans.Transform(xReader, xWriter);
results = SB.ToString();
xWriter.Close();
xReader.Close();
SR.Dispose();
SR = null;
SW.Dispose();
SW = null;
}
catch (Exception ex)
{
throw new Exception("Could not transform Design XML.", ex);
}
#endregion
return results;
}
示例4: button_Refresh_Click
private void button_Refresh_Click(object sender, EventArgs e)
{
listView_Log.Items.Clear();
String file_name = comboBox_LogFile.Text;
int lines_to_show = Convert.ToInt32(numericUpDown_Lines.Value);
long chunk_size = 65536;
long file_offset = 0;
iControl.SystemConfigSyncFileTransferContext ctx;
String log_buffer = "";
System.IO.StringWriter sw = new System.IO.StringWriter();
if ( file_name.Trim().Length > 0 )
{
do
{
ctx = Clients.ConfigSync.download_file(file_name, chunk_size, ref file_offset);
//log_buffer = log_buffer + Convert.ToString(ctx.file_data);
for (int i = 0; i < ctx.file_data.Length; i++)
{
sw.Write((char)ctx.file_data[i]);
}
} while (!isEof(ctx));
}
// process log buffer
log_buffer = sw.ToString();
System.IO.StringReader sr = new System.IO.StringReader(log_buffer);
int total_lines = 0;
String sLine = null;
while (null != (sLine = sr.ReadLine()))
{
total_lines++;
}
sr.Dispose();
int start_line = 0;
if (total_lines > lines_to_show)
{
start_line = total_lines - lines_to_show;
}
sr = new System.IO.StringReader(log_buffer);
int cur_line = 0;
while (null != (sLine = sr.ReadLine()))
{
if (cur_line >= start_line)
{
processLine(cur_line, sLine);
}
cur_line++;
}
}
示例5: LoadFrom
/// <summary>
/// Loads from the appropriate Data Location. If pass Layout as null this is a REMOTE NOTE load, meaning we are grabbing this information without
/// the layout being loaded into a LayoutPanel.
/// </summary>
/// <param name='GUID'>
/// The unique identifier representing this Layout
/// </param>
/// <returns>
/// <c>true</c>, if from was loaded, <c>false</c> otherwise.
/// </returns>
/// <param name='Layout'>
///
/// </param>
public bool LoadFrom(LayoutPanelBase LayoutPanelToLoadNoteOnto)
{
BaseDatabase MyDatabase = CreateDatabase ();
if (MyDatabase == null) {
throw new Exception ("Unable to create database in LoadFrom");
}
bool Success = false;
List<object[]> myList = null;
// we only care about FIRST ROW. THere should never be two matches on a GUID
TimeSpan time;
time = CoreUtilities.TimerCore.Time (() => {
myList = MyDatabase.GetValues (dbConstants.table_name, dbConstants.Columns
, dbConstants.GUID, LayoutGUID);
});
lg.Instance.Line ("LayoutDatabase->LoadFrom", ProblemType.TIMING, String.Format ("GETVALUES for {0} took {1}", this.ToString (), time));
if (myList != null)
{
if (myList.Count > 0) {
object[] result = myList [0];
// result [0] = id?
// result [1] = guid?
// result [2] = xm
// deserialize from database and load into memor
if (result != null && result.Length > 0) {
//
// LINK TABLE SECTION, start
//
// skip linktables if we are a child
// LayoutPanelToLoadNoteOnto will be null when doing searches, which mean swe should not
// try to load link tables, for sure.
if (false == IsSubPanel && LayoutPanelToLoadNoteOnto != null) {
// Deal with LINKTABLE first, as it causes complexity elsewhere
NoteDataXML_Table table = new NoteDataXML_Table ();
lg.Instance.Line ("LayoutDatabase->LoadFrom", ProblemType.MESSAGE, "LinkTableLoadData = " + result [dbConstants.LINKTABLE.Index].ToString ());
if (result [dbConstants.LINKTABLE.Index].ToString () != Constants.BLANK) {
time = CoreUtilities.TimerCore.Time (() => {
// Loading existing table
System.IO.StringReader LinkTableReader = new System.IO.StringReader (result [dbConstants.LINKTABLE.Index].ToString ());
System.Xml.Serialization.XmlSerializer LinkTableXML = new System.Xml.Serialization.XmlSerializer (typeof(NoteDataXML_Table));
table = (NoteDataXML_Table)LinkTableXML.Deserialize (LinkTableReader);
// if (table != null)
// {
// MyLinkTable.SetTable (table.dataSource);
// }
//NewMessage.Show("Loading a link table with GUID = " + table.GuidForNote);
LinkTableXML = null;
LinkTableReader.Close ();
LinkTableReader.Dispose ();
});
lg.Instance.Line ("LayoutDatabase->LoadFrom", ProblemType.TIMING, String.Format ("LINKTABLE for {0} took {1}", this.ToString (), time));
}
time = CoreUtilities.TimerCore.Time (() => {
CreateLinkTableIfNecessary (table, LayoutPanelToLoadNoteOnto);
});
lg.Instance.Line ("LayoutDatabase->LoadFrom", ProblemType.TIMING, String.Format ("CREATELINKTABLE for {0} took {1}", this.ToString (), time));
}
//
// LINK TABLE SECTION, end
//
time = CoreUtilities.TimerCore.Time (() => {
// Fill in LAYOUT specific details
Status = result [dbConstants.STATUS.Index].ToString ();
Name = result [dbConstants.NAME.Index].ToString ();
if (result [dbConstants.SHOWTABS.Index].ToString () != Constants.BLANK) {
ShowTabs = (bool)result [dbConstants.SHOWTABS.Index];
} else {
//ToDo: This does not seem growable easily
ShowTabs = true;
}
if (result [dbConstants.SUBPANEL.Index].ToString () != Constants.BLANK) {
IsSubPanel = (bool)result [dbConstants.SUBPANEL.Index];
} else {
IsSubPanel = false;
//.........这里部分代码省略.........
示例6: WikipediaResponse
/// <summary>
/// Construct WikipediaResponse by parsing attributes from XML.
/// </summary>
/// <param name="responseXml">XML to parse</param>
public WikipediaResponse(string responseXml)
{
var reader = new System.IO.StringReader(responseXml);
XElement root = XElement.Load(reader);
FullUrl = root.Descendants("page").First().Attribute("fullurl").Value;
string article = root.Descendants("page").Descendants("extract").FirstOrDefault().Value;
Article = article.Replace('\n', ' ');
Title = root.Descendants("page").First().Attribute("title").Value;
reader.Dispose();
}
示例7: CompilePreviewPages
void CompilePreviewPages(System.Drawing.Printing.PrintPageEventArgs e)
{
Application.DoEvents();
Font printFont = FontProvider.GetFont(document.Cpi);
string source = document.ToString(fromPage);
System.IO.StringReader sr = new System.IO.StringReader(source);
float height = e.MarginBounds.Height / document.PageHeight;
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
float yPos = topMargin;
while (true)
{
string line = sr.ReadLine();
if (line != null)
{
e.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos);
//yPos += (printFont.GetHeight(e.Graphics)-3);
yPos += height;
}
else
{
break;
}
}
e.HasMorePages = ++fromPage < document.Count;
printFont.Dispose();
sr.Close();
sr.Dispose();
}
示例8: CustomValidator1_ServerValidate
protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
args.IsValid = true;
System.IO.StringReader sw = new System.IO.StringReader(ImportField.Text);
string splitCharacter = ",";
string lineToProcess = string.Empty;
lineToProcess = sw.ReadLine();
while (lineToProcess != null)
{
string[] lineValues = lineToProcess.Split(splitCharacter.ToCharArray());
if (lineValues.Length > 0)
{
string EmailAddress = lineValues[0];
System.Text.RegularExpressions.Regex re
= new System.Text.RegularExpressions.Regex("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*",
System.Text.RegularExpressions.RegexOptions.Compiled);
if (re.Match(EmailAddress).Value != EmailAddress)
{
args.IsValid = false;
return;
}
}
lineToProcess = sw.ReadLine();
}
sw.Dispose();
}