Changeset 1419 for branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/KeyValuePairDecomposer.cs
- Timestamp:
- 03/25/09 17:16:32 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/KeyValuePairDecomposer.cs
r1405 r1419 1 1 using System; 2 using System.Linq; 2 3 using System.Collections; 3 4 using System.Collections.Generic; … … 16 17 } 17 18 18 public IEnumerable DeCompose(object o) {19 public IEnumerable<Tag> DeCompose(object o) { 19 20 Type t = o.GetType(); 20 yield return t.GetProperty("Key").GetValue(o, null);21 yield return t.GetProperty("Value").GetValue(o, null);21 yield return new Tag("key", t.GetProperty("Key").GetValue(o, null)); 22 yield return new Tag("value", t.GetProperty("Value").GetValue(o, null)); 22 23 } 23 24 24 public object Compose(IEnumerable o, Type t) { 25 return Activator.CreateInstance(t, 26 new List<object>((IEnumerable<object>)o).ToArray()); 25 public object CreateInstance(Type type) { 26 return null; 27 } 28 29 public object Populate(object instance, IEnumerable<Tag> o, Type t) { 30 IEnumerator<Tag> iter = o.GetEnumerator(); 31 iter.MoveNext(); 32 object key = iter.Current.Value; 33 iter.MoveNext(); 34 object value = iter.Current.Value; 35 return Activator.CreateInstance(t, new object[] { key, value }); 27 36 } 28 37 }
Note: See TracChangeset
for help on using the changeset viewer.