Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/03/19 11:59:10 (6 years ago)
Author:
gkronber
Message:

#2520 replaced static type registration in HL.Persistence plugin with the KnownStorableTypesMap which is discovered and used by HEAL.Fossil.
As a consequence we do not need to explicitly call type registration for unit tests.
This change has been necessary because on the first access of StaticCache all StoraleTypes are registered. However, when the HL.Persistence plugin is loaded we have not yet loaded all plugins and as a consequence we would miss StorableTypes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Plugin.cs.frame

    r16482 r16485  
    2121
    2222using HeuristicLab.PluginInfrastructure;
    23 using HEAL.Fossil;
    24 using System;
    2523
    2624namespace HeuristicLab.Persistence {
     
    3230  [PluginFile("HeuristicLab.Persistence-3.3.dll", PluginFileType.Assembly)]
    3331  [PluginDependency("HeuristicLab.Tracing", "3.3")]
    34   public class HeuristicLabPersistencePlugin : PluginBase {
    35 
    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   }
     32  public class HeuristicLabPersistencePlugin : PluginBase { }
    7033}
Note: See TracChangeset for help on using the changeset viewer.