本文整理汇总了C#中System.IO.TextWriter.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# TextWriter.Flush方法的具体用法?C# TextWriter.Flush怎么用?C# TextWriter.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.TextWriter
的用法示例。
在下文中一共展示了TextWriter.Flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Escher
/**
* Constructor
*
* @param w The workbook to interrogate
* @param out The output stream to which the CSV values are written
* @param encoding The encoding used by the output stream. Null or
* unrecognized values cause the encoding to default to UTF8
* @exception java.io.IOException
*/
public Escher(Workbook w, TextWriter os, string encoding)
{
if (encoding == null || encoding == "UnicodeBig")
{
encoding = "UTF8";
}
try
{
for (int i = 0; i < w.getNumberOfSheets(); i++)
{
SheetImpl s = (SheetImpl)w.getSheet(i);
os.Write(s.getName());
os.WriteLine();
os.WriteLine();
DrawingData dd = s.getDrawingData();
if (dd != null)
{
EscherDisplay ed = new EscherDisplay(dd, os);
ed.display();
}
os.WriteLine();
os.WriteLine();
os.Flush();
}
os.Flush();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
示例2: print
/**
* Prettyprint the object to the outputstream.
*/
public static void print(object o, TextWriter w, bool typeheader) {
if (o == null) {
if(typeheader) w.WriteLine("null object");
w.WriteLine("null");
w.Flush();
return;
}
if (o is IDictionary) {
if(typeheader) w.WriteLine("hashtable");
IDictionary map=(IDictionary)o;
w.Write("{");
foreach(object key in map.Keys) {
w.Write(key.ToString()+"="+map[key].ToString()+", ");
}
w.WriteLine("}");
} else if (o is string) {
if(typeheader) w.WriteLine("String");
w.WriteLine(o.ToString());
} else if (o is DateTime) {
if(typeheader) w.WriteLine("DateTime");
w.WriteLine((DateTime)o);
} else if (o is IEnumerable) {
if(typeheader) w.WriteLine(o.GetType().Name);
writeEnumerable(o, w);
w.WriteLine("");
} else {
if(typeheader) w.WriteLine(o.GetType().Name);
w.WriteLine(o.ToString());
}
w.Flush();
}
示例3: TextNullTextWriter
public static void TextNullTextWriter(TextWriter output)
{
output.Flush();
output.Dispose();
output.WriteLine(decimal.MinValue);
output.WriteLine(Math.PI);
output.WriteLine();
output.Flush();
output.Dispose();
}
示例4: Emit
public override void Emit(TextWriter outputWriter)
{
if(TableNavigator.Select("rc:DefaultValues/rc:Value",VulcanPackage.VulcanConfig.NamespaceManager).Count == 0)
{
outputWriter.Flush();
return;
}
StringBuilder columnBuilder = new StringBuilder();
bool containsIdentities = _tableHelper.KeyColumnType == KeyColumnType.Identity;
foreach (XPathNavigator nav in TableNavigator.Select("rc:Columns/rc:Column", VulcanPackage.VulcanConfig.NamespaceManager))
{
/* Build Column List */
string columnName = nav.SelectSingleNode("@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;
columnBuilder.AppendFormat(
"[{0}],",
columnName
);
}
columnBuilder.Remove(columnBuilder.Length - 1, 1);
if (containsIdentities)
{
outputWriter.Write("\n");
outputWriter.Write(String.Format(System.Globalization.CultureInfo.InvariantCulture,"\nSET IDENTITY_INSERT {0} ON\n", TableName));
}
TemplateEmitter te = new TemplateEmitter("InsertDefaultValues",VulcanPackage,null);
outputWriter.Write("\n");
foreach (XPathNavigator nav in TableNavigator.Select("rc:DefaultValues/rc:Value", VulcanPackage.VulcanConfig.NamespaceManager))
{
te.SetParameters(TableName, columnBuilder.ToString(),nav.Value);
te.Emit(outputWriter);
outputWriter.Write("\n"); ;
}
if (containsIdentities)
{
outputWriter.Write(String.Format(System.Globalization.CultureInfo.InvariantCulture,"\nSET IDENTITY_INSERT {0} OFF", TableName));
}
outputWriter.Write("\nGO\n");
outputWriter.Flush();
}
示例5: saveVolume
/// <summary>
/// Primary constructor
/// </summary>
public saveVolume(string u, string p)
{
m_username = u;
m_password = p;
OutputFolder = TA.DirectoryNames.GetDirectoryName(ext: "ttapiContractVolume") +
TA.DirectoryNames.GetDirectoryExtension(DateTime.Now.Date);
System.IO.Directory.CreateDirectory(OutputFolder);
ilsUpdateList = new List<EventHandler<InstrumentLookupSubscriptionEventArgs>>();
sw = new StreamWriter(OutputFolder + "/ContractList.csv");
sw.WriteLine("{0},{1},{2},{3},{4}", "InstrumentName",
"MarketKey",
"ProductType",
"ProductName",
"Volume");
sw.Flush();
TTAPISubs = new ttapiUtils.Subscription(m_username, m_password);
IlsDictionary = TTAPISubs.IlsDictionary;
TTAPISubs.asu_update = TTAPISubs.startProductLookupSubscriptions;
TTAPISubs.PLSEventHandler = TTAPISubs.Subscribe2InstrumentCatalogs;
TTAPISubs.ICUEventHandler = TTAPISubs.StartInstrumentLookupSubscriptionsFromCatalog;
ilsUpdateList.Add(TTAPISubs.startPriceSubscriptions);
TTAPISubs.priceUpdatedEventHandler = WriteVolume2File;
TTAPISubs.ilsUpdateList = ilsUpdateList;
}
示例6: WriteCurrentLineToFile
/// <summary>
/// Writes the current line to the file using the given open text writer.
/// This clears the current line after writing.
/// </summary>
public void WriteCurrentLineToFile( TextWriter writer )
{
line = line.TrimEnd( delimiter );
writer.WriteLine( line );
writer.Flush();
line = "";
}
示例7: GenerateResult
public static void GenerateResult (TextReader sr, TextWriter sw, Uri baseUri)
{
while (sr.Peek () > 0) {
string uriString = sr.ReadLine ();
if (uriString.Length == 0 || uriString [0] == '#')
continue;
Uri uri = (baseUri == null) ?
new Uri (uriString) : new Uri (baseUri, uriString);
sw.WriteLine ("-------------------------");
sw.WriteLine (uriString);
sw.WriteLine (uri.ToString ());
sw.WriteLine (uri.AbsoluteUri);
sw.WriteLine (uri.Scheme);
sw.WriteLine (uri.Host);
sw.WriteLine (uri.LocalPath);
sw.WriteLine (uri.Query);
sw.WriteLine (uri.Port);
sw.WriteLine (uri.IsFile);
sw.WriteLine (uri.IsUnc);
sw.WriteLine (uri.IsLoopback);
sw.WriteLine (uri.UserEscaped);
sw.WriteLine (uri.HostNameType);
sw.WriteLine (uri.AbsolutePath);
sw.WriteLine (uri.PathAndQuery);
sw.WriteLine (uri.Authority);
sw.WriteLine (uri.Fragment);
sw.WriteLine (uri.UserInfo);
sw.Flush ();
}
sr.Close ();
sw.Close ();
}
示例8: LogTextWriter
public LogTextWriter(string filePath, string prefix = null, string suffix = null, string newline = "\n")
{
_outputQueue = new ConcurrentQueue<string>();
_outputRun = 1;
_outputThread = new Thread(() =>
{
string o;
using (FileStream _fs = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
{
_innerWriter = new StreamWriter(_fs);
_innerWriter.NewLine = newline;
while (Thread.VolatileRead(ref _outputRun) == 1 || _outputQueue.Count > 0)
{
if (_outputQueue.Count > 0)
{
while (_outputQueue.TryDequeue(out o))
_innerWriter.Write(o);
_innerWriter.Flush();
}
else
Thread.Sleep(_outputThreadDelay);
}
// _fs.Close();
_innerWriter.Close();
}
});
_outputThread.Priority = ThreadPriority.BelowNormal;
_outputThread.Start();
_prefix = prefix;
_suffix = suffix;
}
示例9: EscherDrawingGroup
/**
* Constructor
*
* @param w The workbook to interrogate
* @param out The output stream to which the CSV values are written
* @param encoding The encoding used by the output stream. Null or
* unrecognized values cause the encoding to default to UTF8
* @exception java.io.IOException
*/
public EscherDrawingGroup(Workbook w, TextWriter os, string encoding)
{
if (encoding == null || encoding != "UnicodeBig")
{
encoding = "UTF8";
}
try
{
WorkbookParser wp = (WorkbookParser)w;
DrawingGroup dg = wp.getDrawingGroup();
if (dg != null)
{
EscherDisplay ed = new EscherDisplay(dg, os);
ed.display();
}
os.WriteLine();
os.WriteLine();
os.Flush();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
示例10: Render
/// <summary>
/// Renders the view into the given <see cref="TextWriter"/>.
/// </summary>
/// <param name="viewContext">Contains the view data model.</param>
/// <param name="writer">The <see cref="TextWriter"/> used to write the rendered output.</param>
public void Render(ViewContext viewContext, TextWriter writer)
{
var content = Razor.Parse(_template, viewContext.ViewData.Model, _resourcePath);
writer.Write(content);
writer.Flush();
}
示例11: Render
public void Render(ViewContext viewContext, TextWriter writer)
{
var content = Razor.Parse(template, viewContext.ViewData.Model, cacheName);
writer.Write(content);
writer.Flush();
}
示例12: Evaluate
public void Evaluate(IDictionary<string, object> context, TextReader input, TextWriter output)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
if (input == null)
{
throw new ArgumentNullException("input");
}
if (output == null)
{
throw new ArgumentNullException("output");
}
var vctx = this.CreateVelocityContext(context);
//执行渲染
var successed = this.engine.Evaluate(vctx, output, "VelocityTextTemplateEngine", input);
output.Flush();
if (!successed)
{
throw new TemplateException("Failed to render template");
}
}
示例13: Save
public void Save(IGraph g, TextWriter output)
{
JToken flattened = MakeExpandedForm(g);
output.Write(flattened);
output.Flush();
}
示例14: Save
public void Save(IGraph g, TextWriter output)
{
JToken flattened = MakeExpandedForm(g);
output.Write(flattened.ToString(Formatting.None, new JsonConverter[0]));
output.Flush();
}
示例15: WriteToStream
public static void WriteToStream(TextWriter stream, DataTable table, bool header, bool quoteall)
{
if (header)
{
for (int i = 0; i < table.Columns.Count; i++)
{
WriteItem(stream, table.Columns[i].Caption, quoteall);
if (i < table.Columns.Count - 1)
stream.Write(',');
else
stream.Write("\r\n");
}
}
foreach (DataRow row in table.Rows)
{
for (int i = 0; i < table.Columns.Count; i++)
{
WriteItem(stream, row[i], quoteall);
if (i < table.Columns.Count - 1)
stream.Write(',');
else
stream.Write("\r\n");
}
}
stream.Flush();
stream.Close();
}