Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5714


Ignore:
Timestamp:
03/16/11 15:12:12 (12 years ago)
Author:
mkommend
Message:

#1442: Corrected bug in TupleSerializer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TupleSerializer.cs

    r5698 r5714  
    6363    public IEnumerable<Tag> CreateMetaInfo(object obj) {
    6464      Type t = obj.GetType();
    65       for (int i = 1; i<=t.GetGenericArguments().Length; i++) {
     65      for (int i = 1; i <= t.GetGenericArguments().Length; i++) {
    6666        string name = string.Format("Item{0}", i);
    6767        yield return new Tag(name, t.GetProperty(name).GetValue(obj, null));
     
    7979    static TupleSerializer() {
    8080      foreach (MethodInfo mi in typeof(Tuple).GetMethods(public_static).Where(mi => mi.Name == "Create")) {
    81         CreateMethods[mi.GetGenericArguments().Length-1] = mi;
     81        CreateMethods[mi.GetGenericArguments().Length - 1] = mi;
    8282      }
    8383    }
     
    8585    public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) {
    8686      var values = metaInfo.Select(t => t.Value).ToArray();
    87       MethodInfo createMethod = CreateMethods[values.Length-1].MakeGenericMethod(values.Select(v => v.GetType()).ToArray());
    88       return createMethod.Invoke(null, values.ToArray());
     87      MethodInfo createMethod = CreateMethods[values.Length - 1].MakeGenericMethod(type.GetGenericArguments());
     88      return createMethod.Invoke(null, values);
    8989    }
    9090
Note: See TracChangeset for help on using the changeset viewer.