Changeset 5714 for trunk/sources/HeuristicLab.Persistence/3.3/Default
- Timestamp:
- 03/16/11 15:12:12 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TupleSerializer.cs
r5698 r5714 63 63 public IEnumerable<Tag> CreateMetaInfo(object obj) { 64 64 Type t = obj.GetType(); 65 for (int i = 1; i <=t.GetGenericArguments().Length; i++) {65 for (int i = 1; i <= t.GetGenericArguments().Length; i++) { 66 66 string name = string.Format("Item{0}", i); 67 67 yield return new Tag(name, t.GetProperty(name).GetValue(obj, null)); … … 79 79 static TupleSerializer() { 80 80 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; 82 82 } 83 83 } … … 85 85 public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) { 86 86 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); 89 89 } 90 90
Note: See TracChangeset
for help on using the changeset viewer.