Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/16/11 14:47:32 (14 years ago)
Author:
mkommend
Message:

#1418: Fixed persistence of SymbolicExpressionGrammars.

Location:
branches/DataAnalysis Refactoring/HeuristicLab.Persistence/3.3
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TupleSerializer.cs

    r5698 r5712  
    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());
     87
     88      MethodInfo createMethod = CreateMethods[values.Length - 1].MakeGenericMethod(type.GetGenericArguments());
    8889      return createMethod.Invoke(null, values.ToArray());
    8990    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj

    r5290 r5712  
    142142    <Compile Include="Default\CompositeSerializers\CompactNumberArray2StringSerializer.cs" />
    143143    <Compile Include="Default\CompositeSerializers\ConcreteDictionarySerializer.cs" />
     144    <Compile Include="Default\CompositeSerializers\TupleSerializer.cs" />
    144145    <Compile Include="Default\CompositeSerializers\HashSetSerializer.cs" />
    145146    <Compile Include="Default\CompositeSerializers\DictionarySerializer.cs" />
  • branches/DataAnalysis Refactoring/HeuristicLab.Persistence/3.3/Tests/UseCases.cs

    r5445 r5712  
    12431243    }
    12441244
     1245    [TestMethod]
     1246    public void TupleTest() {
     1247      var t1 = Tuple.Create(1);
     1248      var t2 = Tuple.Create('1', "2");
     1249      var t3 = Tuple.Create(3.0, 3f, 5);
     1250      var t4 = Tuple.Create(Tuple.Create(1, 2, 3), Tuple.Create(4, 5, 6), Tuple.Create(8, 9, 10));
     1251      var tuple = Tuple.Create(t1, t2, t3, t4);
     1252      XmlGenerator.Serialize(tuple, tempFile);
     1253      var newTuple = XmlParser.Deserialize<Tuple<Tuple<int>, Tuple<char, string>, Tuple<double, float, int>, Tuple<Tuple<int, int, int>, Tuple<int, int, int>, Tuple<int, int, int>>>>(tempFile);
     1254      Assert.AreEqual(tuple, newTuple);
     1255    }
     1256
    12451257
    12461258
Note: See TracChangeset for help on using the changeset viewer.