Last change
on this file since 1463 was
1454,
checked in by epitzer, 16 years ago
|
merge persistence exploration branch into trunk as HL plugin. (#506)
|
File size:
840 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Text;
|
---|
3 | using HeuristicLab.Persistence.Core;
|
---|
4 | using HeuristicLab.Persistence.Interfaces;
|
---|
5 |
|
---|
6 | namespace HeuristicLab.Persistence.Default.Xml.Primitive {
|
---|
7 |
|
---|
8 | [EmptyStorableClass]
|
---|
9 | public class String2XmlFormatter : IFormatter {
|
---|
10 |
|
---|
11 | public Type Type { get { return typeof(string); } }
|
---|
12 | public IFormat Format { get { return XmlFormat.Instance; } }
|
---|
13 |
|
---|
14 | public object DoFormat(object o) {
|
---|
15 | return "<![CDATA[" +
|
---|
16 | ((string)o).Replace("]]>", "]]]]><![CDATA[>") +
|
---|
17 | "]]>";
|
---|
18 | }
|
---|
19 |
|
---|
20 | public object Parse(object o) {
|
---|
21 | StringBuilder sb = new StringBuilder();
|
---|
22 | foreach (string s in ((string)o).Split(
|
---|
23 | new[] { "<![CDATA[", "]]>" },
|
---|
24 | StringSplitOptions.RemoveEmptyEntries)) {
|
---|
25 | sb.Append(s);
|
---|
26 | }
|
---|
27 | return sb.ToString();
|
---|
28 | }
|
---|
29 | }
|
---|
30 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.