本文整理汇总了C#中TextWriter.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TextWriter.ToString方法的具体用法?C# TextWriter.ToString怎么用?C# TextWriter.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextWriter
的用法示例。
在下文中一共展示了TextWriter.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenForCollaboration
public void OpenForCollaboration(TextWriter x)
{
try
{
StringReader y = new StringReader(x.ToString());
doc = MagicDocument.LoadDocument(y);
doc.Ink.Dirty = false;
HookupOverlayToNewInk();
}
catch (IOException ex)
{
MessageBox.Show(
ex.Message,
Application.ProductName,
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
}
示例2: Process
public string Process(string s)
{
fmtfolder = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath;
fmtfolder = Path.Combine(Path.GetDirectoryName(fmtfolder), "LPfmt");
using (sw = new StringWriter())
{
int length;
List<LpItem> items = LpParser.Parse(s, 0, out length);
var templates = from item in items
where item is LpTemplate
select item as LpTemplate;
foreach (LpTemplate template in templates)
{
if (template.Name == "MatchList")
{
int matchno = 1;
while (true)
{
List<LpItem> contents;
if (!template.Params.TryGetValue("match" + matchno.ToString(), out contents))
break;
if (contents.Count == 1 && contents[0] is LpTemplate)
TryProcessMatchMaps(contents[0] as LpTemplate);
matchno++;
}
sw.WriteLine();
continue;
}
if (TryProcessMatchMaps(template))
{
sw.WriteLine();
continue;
}
if (TryProcessBracket(template))
{
sw.WriteLine();
continue;
}
// if we ended up here, we don't support this template
//sw.WriteLine("; -- Unsupported template: {0} --", template.Name);
}
string header;
using (StringWriter headerWriter = new StringWriter())
{
if (maps.Count > 0)
{
headerWriter.WriteLine("; maps");
int maxlength = (from map in maps select map.Length).Max();
foreach (string map in maps)
headerWriter.WriteLine("$map {0} = {1}", map.PadRight(maxlength, ' '), map);
headerWriter.WriteLine();
}
if (players.Count > 0)
{
headerWriter.WriteLine("; players");
int maxlength = (from player in players select player.Length).Max();
foreach (string player in players)
headerWriter.WriteLine("$player {0} = {1}", player.PadRight(maxlength, ' '), player);
headerWriter.WriteLine();
}
header = headerWriter.ToString();
}
return header + sw.ToString();
}
}
示例3: GetMemberCode
private static string GetMemberCode(CodeTypeMember member, TextWriter writer)
{
CodeTypeDeclaration dummyType = new CodeTypeDeclaration();
dummyType.Members.Add(member);
Provider.GenerateCodeFromType(dummyType, writer, null);
string propertyCode = writer.ToString();
StringBuilder propertyCodeBuilder = new StringBuilder(propertyCode);
propertyCodeBuilder.Remove(0, propertyCode.IndexOf('{') + 1);
propertyCodeBuilder.Length -= propertyCode.Length - propertyCode.LastIndexOf('}');
propertyCode = propertyCodeBuilder.ToString();
return propertyCode;
}