Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Plugin.cs.frame @ 16482

Last change on this file since 16482 was 16482, checked in by gkronber, 5 years ago

#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.

File size: 3.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.PluginInfrastructure;
23using HEAL.Fossil;
24using System;
25
26namespace HeuristicLab.Persistence {
27
28  /// <summary>
29  /// The plugin for HeuriticLab.Persistence
30  /// </summary>
31  [Plugin("HeuristicLab.Persistence", "3.3.15.$WCREV$")]
32  [PluginFile("HeuristicLab.Persistence-3.3.dll", PluginFileType.Assembly)]
33  [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  }
70}
Note: See TracBrowser for help on using the repository browser.