- Timestamp:
- 04/16/09 12:58:14 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/ViewOnly/ViewOnlyFormat.cs
r1564 r1566 17 17 18 18 public class ViewOnlyFormat : FormatBase<String> { 19 public override string Name { get { return "ViewOnly"; } } 19 public override string Name { get { return "ViewOnly"; } } 20 20 } 21 21 … … 47 47 [EmptyStorableClass] 48 48 public class Float2ViewFormatter : ValueType2ViewFormatterBase<float> { } 49 49 50 50 public class ViewOnlyGenerator : GeneratorBase<string> { 51 51 … … 58 58 isSepReq = false; 59 59 this.showRefs = showRefs; 60 } 60 } 61 61 62 62 protected override string Format(BeginToken beginToken) { 63 StringBuilder sb = new StringBuilder(); 63 StringBuilder sb = new StringBuilder(); 64 64 if (isSepReq) 65 65 sb.Append(", "); 66 if ( ! string.IsNullOrEmpty(beginToken.Name)) {66 if (!string.IsNullOrEmpty(beginToken.Name)) { 67 67 sb.Append(beginToken.Name); 68 if ( beginToken.Id != null && showRefs) {68 if (beginToken.Id != null && showRefs) { 69 69 sb.Append('['); 70 70 sb.Append(beginToken.Id); 71 71 sb.Append(']'); 72 } 72 } 73 73 } 74 74 sb.Append("("); … … 78 78 79 79 protected override string Format(EndToken endToken) { 80 isSepReq = true; 80 isSepReq = true; 81 81 return ")"; 82 82 } 83 83 84 84 protected override string Format(PrimitiveToken primitiveToken) { 85 StringBuilder sb = new StringBuilder(); 85 StringBuilder sb = new StringBuilder(); 86 86 if (isSepReq) 87 87 sb.Append(", "); 88 if ( ! string.IsNullOrEmpty(primitiveToken.Name)) {88 if (!string.IsNullOrEmpty(primitiveToken.Name)) { 89 89 sb.Append(primitiveToken.Name); 90 if ( primitiveToken.Id != null && showRefs) {90 if (primitiveToken.Id != null && showRefs) { 91 91 sb.Append('['); 92 92 sb.Append(primitiveToken.Id); … … 96 96 } 97 97 sb.Append(((String)primitiveToken.SerialData).Data); 98 isSepReq = true; 99 return sb.ToString(); 98 isSepReq = true; 99 return sb.ToString(); 100 100 } 101 101 … … 104 104 if (isSepReq) 105 105 sb.Append(", "); 106 if ( ! string.IsNullOrEmpty(referenceToken.Name)) {106 if (!string.IsNullOrEmpty(referenceToken.Name)) { 107 107 sb.Append(referenceToken.Name); 108 108 sb.Append('='); … … 111 111 sb.Append(referenceToken.Id); 112 112 sb.Append('}'); 113 isSepReq = true; 113 isSepReq = true; 114 114 return sb.ToString(); 115 115 } … … 141 141 142 142 public static string Serialize(object o, Configuration configuration) { 143 Serializer s = new Serializer(o, configuration); 143 Serializer s = new Serializer(o, configuration); 144 144 ViewOnlyGenerator generator = new ViewOnlyGenerator(); 145 145 StringBuilder sb = new StringBuilder(); 146 146 foreach (ISerializationToken token in s) { 147 sb.Append(generator.Format(token)); 147 sb.Append(generator.Format(token)); 148 148 } 149 149 return sb.ToString();
Note: See TracChangeset
for help on using the changeset viewer.