- Timestamp:
- 11/24/15 16:59:57 (9 years ago)
- Location:
- branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/ProtoBufSerializer.cs
r13347 r13367 29 29 30 30 protected override Bundle DeserializeBundle(Stream stream) { 31 return Bundle.ParseFrom(stream );31 return Bundle.ParseFrom(stream, Mapper.StaticCache.GetExtensionRegistry()); 32 32 } 33 33 } -
branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/StaticCache.cs
r13358 r13367 36 36 private Dictionary<Type, Guid> type2Guid; 37 37 private Dictionary<Type, TypeInfo> typeInfos; 38 private ExtensionRegistry extensionRegistry; 38 39 39 40 internal StaticCache() { … … 47 48 type2Guid = new Dictionary<Type, Guid>(); 48 49 typeInfos = new Dictionary<Type, TypeInfo>(); 50 extensionRegistry = ExtensionRegistry.CreateInstance(); 49 51 50 foreach (var transformer in ApplicationManager.Manager.GetInstances<ITransformer>().OrderBy(x => x. Order)) {52 foreach (var transformer in ApplicationManager.Manager.GetInstances<ITransformer>().OrderBy(x => x.Priority)) { 51 53 guid2Transformer.Add(transformer.Guid, transformer); 52 54 transformer2Guid.Add(transformer, transformer.Guid); … … 71 73 RegisterType(StorableClassAttribute.GetStorableClassAttribute(t).Guid, t); 72 74 } 75 76 RegisterExtension(BoolBox.Bool); 77 RegisterExtension(IntBox.Int); 78 RegisterExtension(LongBox.Long); 79 RegisterExtension(UnsignedIntBox.UnsignedInt); 80 RegisterExtension(UnsignedLongBox.UnsignedLong); 81 RegisterExtension(FloatBox.Float); 82 RegisterExtension(DoubleBox.Double); 83 RegisterExtension(StringBox.String); 84 RegisterExtension(BytesBox.Bytes); 85 RegisterExtension(BoolArrayBox.BoolArray); 86 RegisterExtension(IntArrayBox.IntArray); 87 RegisterExtension(MatrixBox.Matrix); 88 RegisterExtension(BoolMatrixBox.BoolMatrix); 89 RegisterExtension(IntMatrixBox.IntMatrix); 90 RegisterExtension(DictionaryBox.Dictionary); 73 91 } 74 92 } … … 79 97 type2Guid.Add(type, guid); 80 98 } 99 } 100 public void RegisterExtension<TExtension>(GeneratedExtensionBase<TExtension> extension) { 101 extensionRegistry.Add(extension); 81 102 } 82 103 … … 104 125 } 105 126 } 127 public ExtensionRegistry GetExtensionRegistry() { 128 return extensionRegistry; 129 } 106 130 } 107 131 } -
branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/Transformer.cs
r13358 r13367 25 25 public abstract class Transformer : ITransformer { 26 26 public Guid Guid { get; private set; } 27 public uint Id { get; private set; } 28 public uint Order { get; private set; } 27 public uint Priority { get; private set; } 29 28 30 29 protected Transformer() { 31 30 Guid = TransformerAttribute.GetGuid(this.GetType()); 32 Order = TransformerAttribute.GetOrder(this.GetType()); 33 Id = 0; 34 } 35 36 public void Initialize(uint id) { 37 Id = id; 31 Priority = TransformerAttribute.GetPriority(this.GetType()); 38 32 } 39 33 -
branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/TransformerAttribute.cs
r13347 r13367 26 26 public sealed class TransformerAttribute : Attribute { 27 27 public Guid Guid { get; private set; } 28 public uint Order{ get; private set; }28 public uint Priority { get; private set; } 29 29 30 public TransformerAttribute(string guid, uint order) {30 public TransformerAttribute(string guid, uint priority) { 31 31 Guid = new Guid(guid); 32 Order = order;32 Priority = priority; 33 33 } 34 34 … … 42 42 return GetTransformerAttribute(type).Guid; 43 43 } 44 public static uint Get Order(Type type) {45 return GetTransformerAttribute(type). Order;44 public static uint GetPriority(Type type) { 45 return GetTransformerAttribute(type).Priority; 46 46 } 47 47 }
Note: See TracChangeset
for help on using the changeset viewer.