Changeset 1644 for trunk/sources/HeuristicLab.Persistence/3.3/Default
- Timestamp:
- 04/23/09 17:41:55 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/CompactNumberArray2StringDecomposer.cs
r1625 r1644 17 17 } 18 18 19 private static readonly Number2String Converter numberConverter =20 new Number2String Converter();19 private static readonly Number2StringDecomposer numberConverter = 20 new Number2StringDecomposer(); 21 21 22 22 public bool CanDecompose(Type type) { -
trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/Number2StringConverter.cs
r1625 r1644 9 9 namespace HeuristicLab.Persistence.Default.Decomposers { 10 10 11 public class Number2String Converter {11 public class Number2StringDecomposer : IDecomposer { 12 12 13 13 private static readonly List<Type> numberTypes = … … 29 29 private static readonly Dictionary<Type, MethodInfo> numberParsers; 30 30 31 static Number2String Converter() {31 static Number2StringDecomposer() { 32 32 numberParsers = new Dictionary<Type, MethodInfo>(); 33 33 foreach (var type in numberTypes) { … … 65 65 } 66 66 67 68 #region IDecomposer Members 69 70 public int Priority { 71 get { return -100; } 72 } 73 74 public IEnumerable<Tag> CreateMetaInfo(object obj) { 75 yield return new Tag(Format(obj)); 76 } 77 78 public IEnumerable<Tag> Decompose(object obj) { 79 // numbers are composed just of meta info 80 return new Tag[] { }; 81 } 82 83 public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) { 84 var it = metaInfo.GetEnumerator(); 85 try { 86 it.MoveNext(); 87 return Parse((string)it.Current.Value, type); 88 } catch (InvalidOperationException e) { 89 throw new PersistenceException( 90 String.Format("Insufficient meta information to reconstruct number of type {0}.", 91 type.VersionInvariantName()), e); 92 } catch (InvalidCastException e) { 93 throw new PersistenceException("Invalid meta information element type", e); 94 } 95 } 96 97 public void Populate(object instance, IEnumerable<Tag> tags, Type type) { 98 // numbers are composed just of meta info, no need to populate 99 } 100 101 #endregion 67 102 } 68 103 -
trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/NumberEnumerable2StringDecomposer.cs
r1625 r1644 17 17 } 18 18 19 private static readonly Number2String Converter numberConverter =20 new Number2String Converter();19 private static readonly Number2StringDecomposer numberConverter = 20 new Number2StringDecomposer(); 21 21 22 22 private static readonly Dictionary<Type, Type> interfaceCache = new Dictionary<Type, Type>();
Note: See TracChangeset
for help on using the changeset viewer.