当前位置: 首页>>代码示例>>C#>>正文


C# StringWriter.toString方法代码示例

本文整理汇总了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);
开发者ID:ngallagher,项目名称:simplexml,代码行数:9,代码来源:MultiThreadedPersisterTest.cs

示例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());
开发者ID:ngallagher,项目名称:simplexml,代码行数:17,代码来源:EmptyMapEntryTest.cs

示例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);
开发者ID:ngallagher,项目名称:simplexml,代码行数:14,代码来源:VisitorStrategyTest.cs

示例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);
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:16,代码来源:ReplaceThisTest.cs

示例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);
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:19,代码来源:PrefixResolverTest.cs

示例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);
开发者ID:ngallagher,项目名称:simplexml,代码行数:23,代码来源:AnnotationCycleStrategyTest.cs

示例7: Format

 public String Format(String source) {
    StringWriter writer = new StringWriter();
    Format(source, writer);
    return writer.toString();
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:5,代码来源:Formatter.cs


注:本文中的StringWriter.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。