Changeset 5712 for branches/DataAnalysis Refactoring/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TupleSerializer.cs
- Timestamp:
- 03/16/11 14:47:32 (13 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TupleSerializer.cs
r5698 r5712 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()); 87 88 MethodInfo createMethod = CreateMethods[values.Length - 1].MakeGenericMethod(type.GetGenericArguments()); 88 89 return createMethod.Invoke(null, values.ToArray()); 89 90 }
Note: See TracChangeset
for help on using the changeset viewer.