Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1519


Ignore:
Timestamp:
04/07/09 12:43:26 (16 years ago)
Author:
epitzer
Message:

Include chain of declaring types for proper type information of nested types. (#575)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence.Test/NewSerializationTest.cs

    r1518 r1519  
    254254    }
    255255
     256    public class NestedType {
     257      [Storable]
     258      private string value = "value";
     259    }
     260
     261    public static void Test7() {
     262      NestedType t = new NestedType();
     263      XmlGenerator.Serialize(t, "test7.zip");
     264      object o = XmlParser.DeSerialize("test7.zip");
     265      Console.WriteLine(ViewOnlyGenerator.Serialize(t));
     266      Console.WriteLine(ViewOnlyGenerator.Serialize(o));
     267    }
     268
    256269
    257270    public static void Main() {
     
    263276      Test5();
    264277      Test6();
     278      Test7();
    265279      //SpeedTest();
    266280      //SpeedTest2();
  • trunk/sources/HeuristicLab.Persistence/Core/TypeStringBuilder.cs

    r1454 r1519  
    66  public static class TypeStringBuilder {
    77
    8     private static void BuildVersionInvariantName(Type type, StringBuilder sb) {   
    9       sb.Append(type.Namespace);
    10       sb.Append('.');
     8    private static void BuildDeclaringTypeChain(Type type, StringBuilder sb) {
     9      if ( type.DeclaringType != null ) {
     10        BuildDeclaringTypeChain(type.DeclaringType, sb);
     11        sb.Append(type.DeclaringType.Name).Append('+');
     12      }
     13    }
     14
     15    private static void BuildVersionInvariantName(Type type, StringBuilder sb) {
     16      sb.Append(type.Namespace).Append('.');
     17      BuildDeclaringTypeChain(type, sb);
    1118      sb.Append(type.Name);
    1219      if (type.IsGenericType) {
     
    1623          sb.Append("[");
    1724          BuildVersionInvariantName(args[i], sb);
    18           sb.Append("]");
    19           sb.Append(",");
     25          sb.Append("],");
    2026        }
    2127        if (args.Length > 0)
     
    2329        sb.Append("]");
    2430      }           
    25       sb.Append(", ");
    26       sb.Append(type.Assembly.GetName().Name);     
     31      sb.Append(", ").Append(type.Assembly.GetName().Name);
    2732    }
    2833
Note: See TracChangeset for help on using the changeset viewer.