本文整理汇总了C#中StringWriter.toString方法的典型用法代码示例。如果您正苦于以下问题:C# StringWriter.toString方法的具体用法?C# StringWriter.toString怎么用?C# StringWriter.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringWriter
的用法示例。
在下文中一共展示了StringWriter.toString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run() {
try {
latch.countDown();
latch.await();
for(int i = 0; i < 100; i++) {
StringWriter writer = new StringWriter();
serializer.Write(example, writer);
String text = writer.toString();
Example copy = serializer.Read(Example.class, text);
示例2: TestEmptyMapEntry
/// <summary>
/// </summary>
/// <param name="args">
/// the command line arguments
/// </param>
public void TestEmptyMapEntry() {
Strategy resolver = new CycleStrategy("id", "ref");
Serializer s = new Persister(resolver);
StringWriter w = new StringWriter();
SimpleBug1 bug1 = new SimpleBug1();
AssertEquals(bug1.test1.data.get("key1"), "value1");
AssertEquals(bug1.test1.data.get("key2"), "value1");
AssertEquals(bug1.test1.data.get("key3"), "");
AssertEquals(bug1.test1.data.get(""), "");
s.write(bug1, w);
System.err.println(w.toString());
SimpleBug1 bug2 = s.read(SimpleBug1.class, w.toString());
示例3: TestStrategy
public void TestStrategy() {
Visitor visitor = new ClassToNamespaceVisitor();
Strategy strategy = new VisitorStrategy(visitor);
Persister persister = new Persister(strategy);
VisitorExample item = new VisitorExample();
StringWriter writer = new StringWriter();
item.Put("1", "ONE");
item.Put("2", "TWO");
item.Add("A");
item.Add("B");
persister.write(item, writer);
String text = writer.toString();
System.out.println(text);
VisitorExample recover = persister.read(VisitorExample.class, text);
示例4: TestReplaceParent
public void TestReplaceParent() {
Persister persister = new Persister();
Set<String> children = new HashSet<String>();
RealParent parent = new RealParent(children);
children.add("Tom");
children.add("Dick");
children.add("Harry");
StringWriter writer = new StringWriter();
persister.write(parent, writer);
String text = writer.toString();
System.out.println(text);
AssertEquals(text.indexOf("Tom"), -1);
AssertEquals(text.indexOf("Dick"), -1);
AssertEquals(text.indexOf("Harry"), -1);
validate(persister, parent);
}
示例5: TestPrefixResolver
public void TestPrefixResolver() {
StringWriter writer = new StringWriter();
OutputNode node = NodeBuilder.write(writer);
// <root xmlns="ns1">
OutputNode root = node.getChild("root");
root.setReference("ns1");
root.getNamespaces().put("ns1", "n");
// <child xmlns="ns2">
OutputNode child = root.getChild("child");
child.setReference("ns2");
child.getNamespaces().put("ns2", "n");
// <grandchild xmlns="ns1">
OutputNode grandchild = child.getChild("grandchild");
grandchild.setReference("ns1");
grandchild.getNamespaces().put("ns1", "n");
root.commit();
String text = writer.toString();
System.out.println(text);
}
示例6: TestCycle
//public List<Entry> GetEntries() {
// return list;
//}
public void TestCycle() {
CycleStrategy inner = new CycleStrategy();
AnnotationStrategy strategy = new AnnotationStrategy(inner);
Persister persister = new Persister(strategy);
EntryListExample list = new EntryListExample();
StringWriter writer = new StringWriter();
Entry a = new Entry("A", "a");
Entry b = new Entry("B", "b");
Entry c = new Entry("C", "c");
Entry primary = new Entry("PRIMARY", "primary");
list.Primary = primary;
list.AddEntry(a);
list.AddEntry(b);
list.AddEntry(c);
list.AddEntry(b);
list.AddEntry(c);
persister.write(list, writer);
persister.write(list, System.out);
String text = writer.toString();
EntryListExample copy = persister.read(EntryListExample.class, text);
示例7: Format
public String Format(String source) {
StringWriter writer = new StringWriter();
Format(source, writer);
return writer.toString();
}