Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/24/09 15:00:50 (15 years ago)
Author:
epitzer
Message:

Separate TypeExtensions into its own file. (#548)

Location:
trunk/sources/HeuristicLab.Persistence.GUI/3.3
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence.GUI/3.3/HeuristicLab.Persistence.GUI-3.3.csproj

    r1534 r1658  
    9393    </Compile>
    9494    <Compile Include="Properties\AssemblyInfo.cs" />
     95    <Compile Include="TypeExtensions.cs" />
    9596  </ItemGroup>
    9697  <ItemGroup>
  • trunk/sources/HeuristicLab.Persistence.GUI/3.3/PersistenceConfigurationForm.cs

    r1654 r1658  
    423423  }
    424424
    425   public class Empty : ISerialData { }
    426 
    427   [EmptyStorableClass]
    428   public class EmptyFormat : FormatBase<Empty> {
    429     public override string Name { get { return "Empty"; } }
    430   }
    431 
    432   [EmptyStorableClass]
    433   public class EmptyFormatter : FormatterBase<Type, Empty> {
    434 
    435     public override Empty Format(Type o) {
    436       return null;
    437     }
    438 
    439     public override Type Parse(Empty o) {
    440       return null;
    441     }
    442   }
    443 
    444   [EmptyStorableClass]
    445   public class FakeBoolean2XmlFormatter : FormatterBase<bool, Empty> {
    446 
    447     public override Empty Format(bool o) {
    448       return null;
    449     }
    450 
    451     public override bool Parse(Empty o) {
    452       return false;
    453     }
    454   }
    455 
    456   [EmptyStorableClass]
    457   public class Int2XmlFormatter : FormatterBase<int, Empty> {
    458 
    459     public override Empty Format(int o) {
    460       return null;
    461     }
    462 
    463     public override int Parse(Empty o) {
    464       return 0;
    465     }
    466 
    467   }
    468 
    469   public static class TypeFormatter {
    470 
    471     public static string SimpleFullName(this Type type) {
    472       StringBuilder sb = new StringBuilder();
    473       SimpleFullName(type, sb);
    474       return sb.ToString();
    475     }
    476 
    477     private static void SimpleFullName(Type type, StringBuilder sb) {
    478       if (type.IsGenericType) {
    479         sb.Append(type.Name, 0, type.Name.LastIndexOf('`'));
    480         sb.Append("<");
    481         foreach (Type t in type.GetGenericArguments()) {
    482           SimpleFullName(t, sb);
    483           sb.Append(", ");
    484         }
    485         sb.Remove(sb.Length - 2, 2);
    486         sb.Append(">");
    487       } else {
    488         sb.Append(type.Name);
    489       }
    490     }
    491 
    492   }
     425 
    493426
    494427}
Note: See TracChangeset for help on using the changeset viewer.