Changeset 16482


Ignore:
Timestamp:
01/02/19 20:17:59 (3 weeks ago)
Author:
gkronber
Message:

#2520: added two custom transformers (for Fonts and Bitmaps) and registered types that are available in .NET Framework but not in .NET Standard 2.0 and added.

Location:
branches/2520_PersistenceReintegration
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj

    r16462 r16482  
    138138    <Compile Include="Auxiliary\TypeNameParser.cs" />
    139139    <Compile Include="Auxiliary\ReflectionTools.cs" />
     140    <Compile Include="Transformers\BitmapTransformer.cs" />
     141    <Compile Include="Transformers\FontTransformer.cs" />
    140142    <None Include="packages.config" />
    141143    <None Include="Plugin.cs.frame" />
     
    305307    </BootstrapperPackage>
    306308  </ItemGroup>
     309  <ItemGroup />
    307310</Project>
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Plugin.cs.frame

    r16453 r16482  
    2121
    2222using HeuristicLab.PluginInfrastructure;
     23using HEAL.Fossil;
     24using System;
    2325
    2426namespace HeuristicLab.Persistence {
     
    3032  [PluginFile("HeuristicLab.Persistence-3.3.dll", PluginFileType.Assembly)]
    3133  [PluginDependency("HeuristicLab.Tracing", "3.3")]
    32   public class HeuristicLabPersistencePlugin : PluginBase { }
     34  public class HeuristicLabPersistencePlugin : PluginBase {
    3335
     36    // register types when the Plugin type is loaded
     37    static HeuristicLabPersistencePlugin() {
     38      RegisterStorableTypes();
     39    }
     40
     41    // This method registers known StorableTypes for persistence.
     42    // It will be called automatically when the plugin is loaded.
     43    // For unit tests it must be called explicitly.
     44    public static void RegisterStorableTypes() {
     45      TryRegisterType(new Guid("ECC12A57-DA8D-43D9-9EC7-FCAC878A4D69"), typeof(System.Drawing.Font));
     46      TryRegisterType(new Guid("494C1352-A1C3-47A3-8754-A0B19B8F1567"), typeof(System.Drawing.FontStyle));
     47      TryRegisterType(new Guid("41147B67-4C7A-4907-9F6C-509568395EDB"), typeof(System.Drawing.GraphicsUnit));
     48      TryRegisterType(new Guid("E8348C94-9817-4164-9C98-377689F83F30"), typeof(System.Drawing.Bitmap));
     49
     50       TryRegisterType(new Guid("4AF3A1F6-49CD-4172-8394-FE464889250E"), Type.GetType("System.CultureAwareRandomizedComparer"));
     51       TryRegisterType(new Guid("4C7F657C-B69E-4D1A-8812-3254D6219FD2"), Type.GetType("System.OrdinalRandomizedComparer"));
     52       TryRegisterType(new Guid("0549A3DF-1FD4-487A-B06B-8C572DFFFBEB"), Type.GetType("System.Security.PermissionTokenKeyComparer"));
     53       TryRegisterType(new Guid("65D2DE74-8BDF-4C74-9005-81A2C3991DC5"), Type.GetType("System.Collections.CompatibleComparer"));
     54       TryRegisterType(new Guid("075827F4-07D9-4E50-9D00-C9FF3E7DCF9A"), Type.GetType("System.Collections.IEqualityComparer"));
     55       TryRegisterType(new Guid("3DA30D50-2337-4487-AECD-F2DB3ECED834"), Type.GetType("System.Collections.StructuralEqualityComparer"));
     56       TryRegisterType(new Guid("8A19DA46-FE80-4776-9DB4-B17E6182D104"), Type.GetType("System.Collections.Generic.SByteEnumEqualityComparer`1"));
     57       TryRegisterType(new Guid("F6F6EFB9-B631-4ACC-9326-F492A6A63011"), Type.GetType("System.Collections.Generic.ShortEnumEqualityComparer`1"));
     58       TryRegisterType(new Guid("BA0AB604-C052-4E08-8F9E-A5D8098F16A6"), Type.GetType("System.Collections.Generic.RandomizedStringEqualityComparer"));
     59       TryRegisterType(new Guid("00C8C940-63D9-43FF-99BA-9C69301BF043"), Type.GetType("System.Collections.Generic.RandomizedObjectEqualityComparer"));
     60    }
     61
     62    private static void TryRegisterType(Guid typeGuid, Type type) {
     63      try {
     64        Mapper.StaticCache.RegisterType(typeGuid, type);
     65      } catch (Exception) {
     66        Tracing.Logger.Warn($"type {type} or guid {typeGuid} is already registerd.");
     67      }
     68    }
     69  }
    3470}
  • branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence.Fossil/UseCases.cs

    r16471 r16482  
    2929using HEAL.Fossil;
    3030using HeuristicLab.Algorithms.GeneticAlgorithm;
     31using HeuristicLab.Analysis;
    3132using HeuristicLab.Common;
     33using HeuristicLab.Data;
    3234using HeuristicLab.Persistence.Core;
    3335using HeuristicLab.Persistence.Default.Xml;
     
    4345    public void CreateTempFile() {
    4446      tempFile = Path.GetTempFileName();
     47      // in HL this is not necessary because RegisterStorableTypes is called when the plugin is loaded
     48      HeuristicLabPersistencePlugin.RegisterStorableTypes();
    4549    }
    4650
     
    150154              }
    151155            } catch (Exception e) {
    152               Console.WriteLine(t.FullName);
     156              Console.WriteLine($"type {t.FullName} in {fileName} is not registered with a GUID in HEAL.Fossil");
    153157              ok = false;
    154158            }
Note: See TracChangeset for help on using the changeset viewer.