Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/25/09 17:16:32 (15 years ago)
Author:
epitzer
Message:

Implement persistence of storables as decomposer. (#506)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/KeyValuePairDecomposer.cs

    r1405 r1419  
    11using System;
     2using System.Linq;
    23using System.Collections;
    34using System.Collections.Generic;
     
    1617    }
    1718
    18     public IEnumerable DeCompose(object o) {     
     19    public IEnumerable<Tag> DeCompose(object o) {     
    1920      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));
    2223    }
    2324
    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 });     
    2736    }   
    2837  }
Note: See TracChangeset for help on using the changeset viewer.