Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/21/09 15:27:35 (15 years ago)
Author:
epitzer
Message:

Improve debugability to investigate failing tests. (#593)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/String2XmlFormatter.cs

    r1570 r1615  
    33using HeuristicLab.Persistence.Interfaces;
    44using System.Text;
     5using System.Text.RegularExpressions;
    56
    67
     
    1011  public class String2XmlFormatter : FormatterBase<string, XmlString> {
    1112
    12     public override XmlString Format(string s) {     
     13    public override XmlString Format(string s) {
    1314      StringBuilder sb = new StringBuilder();
    1415      sb.Append("<![CDATA[");
     
    1819    }
    1920
    20     private static readonly string[] separators = new string[] { "<![CDATA[", "]]>" };
    21 
    22     public override string Parse(XmlString x) {     
     21    public override string Parse(XmlString x) {
    2322      StringBuilder sb = new StringBuilder();
    24       foreach (string s in x.Data.Split(separators,
    25         StringSplitOptions.RemoveEmptyEntries)) {
    26         sb.Append(s);
     23      Regex re = new Regex(@"<!\[CDATA\[((?:[^]]|\](?!\]>))*)\]\]>", RegexOptions.Singleline);
     24      foreach (Match m in re.Matches(x.Data)) {
     25        sb.Append(m.Groups[1]);
    2726      }
    2827      return sb.ToString();
Note: See TracChangeset for help on using the changeset viewer.