- Timestamp:
- 04/16/09 12:40:41 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/ViewOnly/ViewOnlyFormat.cs
r1556 r1564 9 9 namespace HeuristicLab.Persistence.Default.ViewOnly { 10 10 11 public class ViewOnlyFormat : FormatBase { 12 public override string Name { get { return "ViewOnly"; } } 13 public static ViewOnlyFormat Instance = new ViewOnlyFormat(); 11 public class String : ISerialData { 12 public string Data { get; set; } 13 public String(string s) { 14 Data = s; 15 } 14 16 } 15 17 16 public abstract class ValueType2ViewFormatter : IFormatter { 17 public abstract Type Type { get; } 18 public IFormat Format { get { return ViewOnlyFormat.Instance; } } 19 public object DoFormat(object o) { return o; } 20 public object Parse(object o) { 18 public class ViewOnlyFormat : FormatBase<String> { 19 public override string Name { get { return "ViewOnly"; } } 20 } 21 22 public abstract class ValueType2ViewFormatterBase<T> : FormatterBase<T, String> { 23 public override String Format(T o) { return new String(o.ToString()); } 24 public override T Parse(String s) { 21 25 throw new NotImplementedException(); 22 26 } 23 27 } 24 28 25 public class String2ViewFormatter : ValueType2ViewFormatter { 26 public override Type Type { get { return typeof(string); } } 27 } 29 [EmptyStorableClass] 30 public class String2ViewFormatter : ValueType2ViewFormatterBase<string> { } 28 31 29 public class Bool2ViewFormatter : ValueType2ViewFormatter { 30 public override Type Type { get { return typeof(bool); } } 31 } 32 [EmptyStorableClass] 33 public class Bool2ViewFormatter : ValueType2ViewFormatterBase<bool> { } 32 34 33 public class Int2ViewFormatter : ValueType2ViewFormatter { 34 public override Type Type { get { return typeof(int); } } 35 } 35 [EmptyStorableClass] 36 public class Int2ViewFormatter : ValueType2ViewFormatterBase<int> { } 36 37 37 public class Double2ViewFormatter : ValueType2ViewFormatter { 38 public override Type Type { get { return typeof(double); } } 39 } 38 [EmptyStorableClass] 39 public class Double2ViewFormatter : ValueType2ViewFormatterBase<double> { } 40 40 41 public class DateTime2ViewFormatter : ValueType2ViewFormatter { 42 public override Type Type { get { return typeof(DateTime); } } 43 } 41 [EmptyStorableClass] 42 public class DateTime2ViewFormatter : ValueType2ViewFormatterBase<DateTime> { } 44 43 45 public class Type2ViewFormatter : ValueType2ViewFormatter { 46 public override Type Type { get { return typeof(Type); } } 47 } 44 [EmptyStorableClass] 45 public class Type2ViewFormatter : ValueType2ViewFormatterBase<Type> { } 48 46 49 public class Float2ViewFormatter : ValueType2ViewFormatter { 50 public override Type Type { get { return typeof(float); } } 51 } 52 53 public class ViewOnlyGenerator : Generator<string> { 47 [EmptyStorableClass] 48 public class Float2ViewFormatter : ValueType2ViewFormatterBase<float> { } 49 50 public class ViewOnlyGenerator : GeneratorBase<string> { 54 51 55 52 private bool isSepReq; … … 98 95 sb.Append('='); 99 96 } 100 sb.Append( primitiveToken.SerialData);97 sb.Append(((String)primitiveToken.SerialData).Data); 101 98 isSepReq = true; 102 99 return sb.ToString(); … … 140 137 141 138 public static string Serialize(object o) { 142 return Serialize(o, ConfigurationService.Instance.GetDefaultConfig( ViewOnlyFormat.Instance));139 return Serialize(o, ConfigurationService.Instance.GetDefaultConfig(new ViewOnlyFormat())); 143 140 } 144 141
Note: See TracChangeset
for help on using the changeset viewer.