本文整理汇总了C#中System.IO.StringWriter.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# StringWriter.WriteLine方法的具体用法?C# StringWriter.WriteLine怎么用?C# StringWriter.WriteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringWriter
的用法示例。
在下文中一共展示了StringWriter.WriteLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NormalSectionAndKey
public void NormalSectionAndKey() {
StringWriter writer = new StringWriter();
writer.WriteLine("[Logging]");
writer.WriteLine(" great logger = log4net ");
writer.WriteLine(" [Pets] ; pets comment ");
IniReader reader = new IniReader(new StringReader(writer.ToString()));
Assert.AreEqual(IniReadState.Initial, reader.ReadState);
Assert.IsTrue(reader.Read());
Assert.AreEqual(IniReadState.Interactive, reader.ReadState);
Assert.AreEqual(IniType.Section, reader.Type);
Assert.AreEqual("Logging", reader.Name);
Assert.AreEqual("", reader.Value);
Assert.IsNull(reader.Comment);
Assert.IsTrue(reader.Read());
Assert.AreEqual(IniType.Key, reader.Type);
Assert.AreEqual("great logger", reader.Name);
Assert.AreEqual("log4net", reader.Value);
Assert.AreEqual(null, reader.Comment);
Assert.IsTrue(reader.Read());
Assert.AreEqual(IniType.Section, reader.Type);
Assert.AreEqual("Pets", reader.Name);
Assert.AreEqual("", reader.Value);
Assert.IsNull(reader.Comment);
}
示例2: GetOrdervsGRVReport
public ActionResult GetOrdervsGRVReport(DateTimeFromToQuery ins)
{
List<OrdervsGRVReport> report = reportrepo.GetOrdervsGRVReport(ins);
StringWriter sw = new StringWriter();
sw.WriteLine("\"Day\",\"Date\",\"Order Total\",\"Friday Total\",\"GRV Total\",\"Friday Total\"");
string name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment;filename=OrdervsGRV_" + name + ".csv");
Response.ContentType = "text/csv";
foreach (OrdervsGRVReport ex in report)
{
sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\"",
ex.Day
, ex.Date
, ex.OrderTotal
, ex.FridayOrderTotal
, ex.GRVTotal
, ex.FridayGRVTotal));
}
//Response.ClearContent();
//Response.AddHeader("content-disposition", "attachment;filename=MemberDetailReport_" + GroupName + "_" + name + ".zip");
//Response.ContentType = "application/zip";
Response.Write(sw.ToString());
Response.End();
return null;
}
示例3: NormalComment
public void NormalComment() {
StringWriter writer = new StringWriter();
writer.WriteLine("");
writer.WriteLine(" ; Something");
writer.WriteLine(" ; Some comment ");
writer.WriteLine(" ;");
IniReader reader = new IniReader(new StringReader(writer.ToString()));
Assert.AreEqual(IniReadState.Initial, reader.ReadState);
Assert.IsTrue(reader.Read());
Assert.AreEqual(IniReadState.Interactive, reader.ReadState);
Assert.AreEqual(IniType.Empty, reader.Type);
Assert.AreEqual("", reader.Name);
Assert.AreEqual(null, reader.Comment);
Assert.IsTrue(reader.Read());
Assert.AreEqual(IniType.Empty, reader.Type);
Assert.AreEqual("Something", reader.Comment);
Assert.IsTrue(reader.Read());
Assert.AreEqual(IniType.Empty, reader.Type);
Assert.AreEqual("Some comment", reader.Comment);
Assert.IsTrue(reader.Read());
Assert.AreEqual("", reader.Comment);
Assert.IsFalse(reader.Read());
}
示例4: levelIndention
private string levelIndention()
{
var lines = _writer.ToString().ReadLines().ToArray();
if (!lines.Any()) return string.Empty;
var indention = lines.Where(x => x.IsNotEmpty()).Min(s => s.LeadingSpaces());
if (indention == 0) return _writer.ToString();
var writer = new StringWriter();
foreach (var line in lines)
{
if (line.IsEmpty())
{
writer.WriteLine();
}
else
{
writer.WriteLine(line.Substring(indention));
}
}
return writer.ToString();
}
示例5: ConstructorsAmbiguous
/// <summary>
/// Generates a message saying that the constructor is ambiguous.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="bestDirectives">The best constructor directives.</param>
/// <returns>The exception message.</returns>
public static string ConstructorsAmbiguous(IContext context, IGrouping<int, ConstructorInjectionDirective> bestDirectives)
{
using (var sw = new StringWriter())
{
sw.WriteLine("Error activating {0} using {1}", context.Request.Service.Format(), context.Binding.Format(context));
sw.WriteLine("Several constructors have the same priority. Please specify the constructor using ToConstructor syntax or add an Inject attribute.");
sw.WriteLine();
sw.WriteLine("Constructors:");
foreach (var constructorInjectionDirective in bestDirectives)
{
FormatConstructor(constructorInjectionDirective.Constructor, sw);
}
sw.WriteLine();
sw.WriteLine("Activation path:");
sw.WriteLine(context.Request.FormatActivationPath());
sw.WriteLine("Suggestions:");
sw.WriteLine(" 1) Ensure that the implementation type has a public constructor.");
sw.WriteLine(" 2) If you have implemented the Singleton pattern, use a binding with InSingletonScope() instead.");
return sw.ToString();
}
}
示例6: Write
public void Write(DdlRules rules, StringWriter writer)
{
if (rules.TableCreation == CreationStyle.DropThenCreate)
{
writer.WriteLine("DROP TABLE IF EXISTS {0} CASCADE;", Table.QualifiedName);
writer.WriteLine("CREATE TABLE {0} (", Table.QualifiedName);
}
else
{
writer.WriteLine("CREATE TABLE IF NOT EXISTS {0} (", Table.QualifiedName);
}
var length = Columns.Select(x => x.Name.Length).Max() + 4;
Columns.Each(col =>
{
writer.Write($" {col.ToDeclaration(length)}");
if (col == Columns.Last())
{
writer.WriteLine();
}
else
{
writer.WriteLine(",");
}
});
writer.WriteLine(");");
rules.GrantToRoles.Each(role =>
{
writer.WriteLine($"GRANT SELECT ({Columns.Select(x => x.Name).Join(", ")}) ON TABLE {Table.QualifiedName} TO \"{role}\";");
});
}
示例7: ToString
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
StringWriter sw = new StringWriter();
sw.WriteLine("Could not find {0} attribute",this.Message);
sw.WriteLine(base.ToString());
return sw.ToString();
}
示例8: GetFixtureReport
public ActionResult GetFixtureReport(SportCategoryID SC)
{
List<FixturesReport> report = reportRep.GetFixtureReport(SC.SportCategory, SC.Date.Date);
SportCategoryRepository screp = new SportCategoryRepository();
StringWriter sw = new StringWriter();
sw.WriteLine("\"StartTime\",\"TeamA\",\"TeamsB\",\"Field\",\"FixtureId\"");
string name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment;filename=Fixture" + "_" + name + ".csv");
Response.ContentType = "text/csv";
sw.WriteLine("\"Fixtures\"");
sw.WriteLine(SC.SportCategory);
sw.WriteLine(SC.Date.Date);
foreach (FixturesReport ex in report)
{
sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\""
, ex.StartTime
, ex.TeamIdA
, ex.TeamIdB
, ex.Field
, ex.FixturesId
));
}
Response.Write(sw.ToString());
Response.End();
return null;
}
示例9: ConvertDialogScriptToRealScript
public void ConvertDialogScriptToRealScript(Dialog dialog, Game game, CompileMessages errors)
{
string thisLine;
_currentlyInsideCodeArea = false;
_hadFirstEntryPoint = false;
_game = game;
_currentDialog = dialog;
_existingEntryPoints.Clear();
_currentLineNumber = 0;
StringReader sr = new StringReader(dialog.Script);
StringWriter sw = new StringWriter();
sw.Write(string.Format("function _run_dialog{0}(int entryPoint) {1} ", dialog.ID, "{"));
while ((thisLine = sr.ReadLine()) != null)
{
_currentLineNumber++;
try
{
ConvertDialogScriptLine(thisLine, sw, errors);
}
catch (CompileMessage ex)
{
errors.Add(ex);
}
}
if (_currentlyInsideCodeArea)
{
sw.WriteLine("}");
}
sw.WriteLine("return RUN_DIALOG_RETURN; }"); // end the function
dialog.CachedConvertedScript = sw.ToString();
sw.Close();
sr.Close();
}
示例10: Context
/*----------------------------------------------------------------------------------------*/
public static string Context(IContext context)
{
using (var sw = new StringWriter())
{
if (context.IsRoot)
{
sw.Write("active request for {0}", Type(context.Service));
}
else
{
sw.Write("passive injection of service {0} into {1}", Type(context.Service),
InjectionRequest(context));
}
if (context.HasDebugInfo)
{
sw.WriteLine();
sw.Write(" from {0}", context.DebugInfo);
}
if (context.Binding != null)
{
sw.WriteLine();
sw.Write(" using {0}", Binding(context.Binding));
if (context.Binding.HasDebugInfo)
{
sw.WriteLine();
sw.Write(" declared by {0}", context.Binding.DebugInfo);
}
}
return sw.ToString();
}
}
示例11: GetIL
public static string GetIL(this LambdaExpression expression, bool appendInnerLambdas = false)
{
Delegate d = expression.Compile();
MethodInfo method = d.GetMethodInfo();
ITypeFactory typeFactory = GetTypeFactory(expression);
var sw = new StringWriter();
AppendIL(method, sw, typeFactory);
if (appendInnerLambdas)
{
var closure = (Closure)d.Target;
int i = 0;
foreach (object constant in closure.Constants)
{
var innerMethod = constant as DynamicMethod;
if (innerMethod != null)
{
sw.WriteLine();
sw.WriteLine("// closure.Constants[" + i + "]");
AppendIL(innerMethod, sw, typeFactory);
}
i++;
}
}
return sw.ToString();
}
示例12: AppendIL
private static void AppendIL(MethodInfo method, StringWriter sw, ITypeFactory typeFactory)
{
var reader = ILReaderFactory.Create(method);
var exceptions = reader.ILProvider.GetExceptionInfos();
var writer = new RichILStringToTextWriter(sw, exceptions);
sw.WriteLine(".method " + method.ToIL());
sw.WriteLine("{");
sw.WriteLine(" .maxstack " + reader.ILProvider.MaxStackSize);
var sig = reader.ILProvider.GetLocalSignature();
var lsp = new LocalsSignatureParser(reader.Resolver, typeFactory);
var locals = default(Type[]);
if (lsp.Parse(sig, out locals) && locals.Length > 0)
{
sw.WriteLine(" .locals init (");
for (var i = 0; i < locals.Length; i++)
{
sw.WriteLine($" [{i}] {locals[i].ToIL()}{(i != locals.Length - 1 ? "," : "")}");
}
sw.WriteLine(" )");
}
sw.WriteLine();
writer.Indent();
reader.Accept(new ReadableILStringVisitor(writer));
writer.Dedent();
sw.WriteLine("}");
}
示例13: Merge
public void Merge() {
StringWriter textWriter = new StringWriter();
XmlTextWriter xmlWriter = NiniWriter(textWriter);
WriteSection(xmlWriter, "Pets");
WriteKey(xmlWriter, "cat", "muffy");
WriteKey(xmlWriter, "dog", "rover");
WriteKey(xmlWriter, "bird", "tweety");
xmlWriter.WriteEndDocument();
StringReader reader = new StringReader(textWriter.ToString());
XmlTextReader xmlReader = new XmlTextReader(reader);
XmlConfigSource xmlSource = new XmlConfigSource(xmlReader);
StringWriter writer = new StringWriter();
writer.WriteLine("[People]");
writer.WriteLine(" woman = Jane");
writer.WriteLine(" man = John");
IniConfigSource iniSource =
new IniConfigSource(new StringReader(writer.ToString()));
xmlSource.Merge(iniSource);
IConfig config = xmlSource.Configs["Pets"];
Assert.AreEqual(3, config.GetKeys().Length);
Assert.AreEqual("muffy", config.Get("cat"));
Assert.AreEqual("rover", config.Get("dog"));
config = xmlSource.Configs["People"];
Assert.AreEqual(2, config.GetKeys().Length);
Assert.AreEqual("Jane", config.Get("woman"));
Assert.AreEqual("John", config.Get("man"));
}
示例14: GeraArquivoRetornoCarga
/// <summary>
/// Gera o arquivo de retorno de carga quando a partir de um arquivo que já foi gerado
/// </summary>
/// <param name="idArquivo"></param>
/// <returns></returns>
public StringWriter GeraArquivoRetornoCarga(int idArquivo)
{
try
{
using (StringWriter sw = new StringWriter(new System.Globalization.CultureInfo("pt-BR")))
{
//Gero Cabeçalho
sw.WriteLine(ACSOPRGCR_RCabecalhoBD.ConsultaPorIdArquivo(idArquivo).ToString());
//Gero Lote
sw.WriteLine(ACSOPRGCR_RLoteBD.ConsultaPorIdArquivo(idArquivo).ToString());
//Gero detalhe
foreach (var det in ACSOPRGCR_RDetalheBD.ConsultaPorIdArquivo(idArquivo))
sw.WriteLine(det.ToString());
//Gero Rodapé
sw.WriteLine(ACSOPRGCR_RRodapeBD.ConsultaPorIdArquivo(idArquivo));
return sw;
}
}
catch (Exception)
{
throw;
}
}
示例15: AddNewConfigsAndKeys
public void AddNewConfigsAndKeys()
{
// Add some new configs and keys here and test.
StringWriter writer = new StringWriter ();
writer.WriteLine ("[Pets]");
writer.WriteLine (" cat = muffy");
writer.WriteLine (" dog = rover");
IniConfigSource source = new IniConfigSource
(new StringReader (writer.ToString ()));
IConfig config = source.Configs["Pets"];
Assert.AreEqual ("Pets", config.Name);
Assert.AreEqual (2, config.GetKeys ().Length);
IConfig newConfig = source.AddConfig ("NewTest");
newConfig.Set ("Author", "Brent");
newConfig.Set ("Birthday", "February 8th");
newConfig = source.AddConfig ("AnotherNew");
Assert.AreEqual (3, source.Configs.Count);
config = source.Configs["NewTest"];
Assert.IsNotNull (config);
Assert.AreEqual (2, config.GetKeys ().Length);
Assert.AreEqual ("February 8th", config.Get ("Birthday"));
Assert.AreEqual ("Brent", config.Get ("Author"));
}