Changeset 1553 for trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/KeyValuePairDecomposer.cs
- Timestamp:
- 04/14/09 13:23:08 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/KeyValuePairDecomposer.cs
r1542 r1553 21 21 } 22 22 23 public IEnumerable<Tag> Decompose(object o) { 23 public IEnumerable<Tag> CreateMetaInfo(object o) { 24 return new Tag[] { }; 25 } 26 27 public IEnumerable<Tag> Decompose(object o) { 24 28 Type t = o.GetType(); 25 29 yield return new Tag("key", t.GetProperty("Key").GetValue(o, null)); … … 27 31 } 28 32 29 public object CreateInstance(Type type ) {33 public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) { 30 34 return Activator.CreateInstance(type, true); 31 35 } 32 36 33 public objectPopulate(object instance, IEnumerable<Tag> o, Type t) {37 public void Populate(object instance, IEnumerable<Tag> o, Type t) { 34 38 IEnumerator<Tag> iter = o.GetEnumerator(); 39 iter.MoveNext(); 40 t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) 41 .Single(fi => fi.Name == "key").SetValue(instance, iter.Current.Value); 35 42 iter.MoveNext(); 36 FieldInfo keyFieldInfo = 37 t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) 38 .Single(fi => fi.Name == "key"); 39 FieldInfo valueFieldInfo = 40 t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) 41 .Single(fi => fi.Name == "value"); 42 iter.Current.SafeSet(value => keyFieldInfo.SetValue(instance, value)); 43 iter.MoveNext(); 44 iter.Current.SafeSet(value => valueFieldInfo.SetValue(instance, value)); 45 return instance; 46 } 43 t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) 44 .Single(fi => fi.Name == "value").SetValue(instance, iter.Current.Value); 45 } 47 46 } 48 49 47 }
Note: See TracChangeset
for help on using the changeset viewer.