Changeset 4175
- Timestamp:
- 08/06/10 16:59:13 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs
r4068 r4175 94 94 try { 95 95 TryLoadSettings(); 96 } 97 catch (Exception e) { 96 } catch (Exception e) { 98 97 if (throwOnError) { 99 98 throw new PersistenceException("Could not load persistence settings.", e); … … 162 161 if (a != defaultAssembly) 163 162 DiscoverFrom(a); 164 } 165 catch (AppDomainUnloadedException x) { 163 } catch (AppDomainUnloadedException x) { 166 164 Logger.Warn("could not get list of assemblies, AppDomain has already been unloaded", x); 167 165 } … … 207 205 } 208 206 } 209 } 210 catch (ReflectionTypeLoadException e) { 207 } catch (ReflectionTypeLoadException e) { 211 208 Logger.Warn("could not analyse assembly: " + a.FullName, e); 212 209 } … … 223 220 foreach (IPrimitiveSerializer f in PrimitiveSerializers[format.SerialDataType]) { 224 221 if (!primitiveConfig.ContainsKey(f.SourceType)) 225 primitiveConfig.Add(f.SourceType, f);222 primitiveConfig.Add(f.SourceType, (IPrimitiveSerializer)Activator.CreateInstance(f.GetType())); 226 223 } 227 224 } else { … … 234 231 format, 235 232 primitiveConfig.Values, 236 CompositeSerializers.Where((d) => d.Priority > 0) );233 CompositeSerializers.Where((d) => d.Priority > 0).Select(d => (ICompositeSerializer)Activator.CreateInstance(d.GetType()))); 237 234 } 238 235 -
trunk/sources/HeuristicLab.Persistence/3.3/Core/DeSerializer.cs
r4068 r4175 85 85 private readonly Stack<Midwife> parentStack; 86 86 private readonly Dictionary<int, Type> typeIds; 87 private Dictionary<Type, object> serializerInstances; 87 88 88 89 /// <summary> … … 98 99 typeIds = new Dictionary<int, Type>(); 99 100 serializerMapping = new Dictionary<Type, object>(); 101 serializerInstances = new Dictionary<Type, object>(); 100 102 foreach (var typeMapping in typeCache) { 101 103 AddTypeInfo(typeMapping); 102 104 } 103 105 } 104 105 private Dictionary<Type, object> serializerInstances = new Dictionary<Type, object>();106 106 107 107 /// <summary> … … 117 117 Type serializerType = TypeLoader.Load(typeMapping.Serializer); 118 118 object serializer; 119 if (serializerInstances.ContainsKey(serializerType)) 119 if (serializerInstances.ContainsKey(serializerType)) { 120 120 serializer = serializerInstances[serializerType]; 121 else121 } else { 122 122 serializer = Activator.CreateInstance(serializerType, true); 123 serializerInstances.Add(serializerType, serializer); 124 } 123 125 serializerMapping.Add(type, serializer); 124 } 125 catch (PersistenceException) { 126 } catch (PersistenceException) { 126 127 throw; 127 } 128 catch (Exception e) { 128 } catch (Exception e) { 129 129 throw new PersistenceException(string.Format( 130 130 "Could not add type info for {0} ({1})", … … 181 181 try { 182 182 parentStack.Push(new Midwife(type, (ICompositeSerializer)serializerMapping[type], token.Id)); 183 } 184 catch (Exception e) { 183 } catch (Exception e) { 185 184 if (e is InvalidCastException || e is KeyNotFoundException) { 186 185 throw new PersistenceException(String.Format( … … 211 210 id2obj[(int)token.Id] = value; 212 211 SetValue(token.Name, value); 213 } 214 catch (Exception e) { 212 } catch (Exception e) { 215 213 if (e is InvalidCastException || e is KeyNotFoundException) { 216 214 throw new PersistenceException(String.Format( -
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs
r4068 r4175 40 40 [StorableClass] 41 41 public sealed class StorableSerializer : ICompositeSerializer { 42 43 public StorableSerializer() { 44 accessorListCache = new AccessorListCache(); 45 accessorCache = new AccessorCache(); 46 constructorCache = new Dictionary<Type, Constructor>(); 47 hookCache = new Dictionary<HookDesignator, List<StorableReflection.Hook>>(); 48 } 42 49 43 50 #region ICompositeSerializer implementation … … 122 129 try { 123 130 return GetConstructor(type)(); 124 } 125 catch (TargetInvocationException x) { 131 } catch (TargetInvocationException x) { 126 132 throw new PersistenceException( 127 133 "Could not instantiate storable object: Encountered exception during constructor call", … … 174 180 private sealed class AccessorListCache : Dictionary<Type, IEnumerable<DataMemberAccessor>> { } 175 181 private sealed class AccessorCache : Dictionary<MemberInfo, DataMemberAccessor> { } 182 private delegate object Constructor(); 176 183 177 184 #endregion … … 179 186 #region caches 180 187 181 private AccessorListCache accessorListCache = new AccessorListCache(); 182 private AccessorCache accessorCache = new AccessorCache(); 183 184 private delegate object Constructor(); 185 186 private Dictionary<Type, Constructor> constructorCache = 187 new Dictionary<Type, Constructor>(); 188 189 private Dictionary<HookDesignator, List<StorableReflection.Hook>> hookCache = 190 new Dictionary<HookDesignator, List<StorableReflection.Hook>>(); 188 private AccessorListCache accessorListCache; 189 private AccessorCache accessorCache; 190 private Dictionary<Type, Constructor> constructorCache; 191 private Dictionary<HookDesignator, List<StorableReflection.Hook>> hookCache; 191 192 192 193 #endregion
Note: See TracChangeset
for help on using the changeset viewer.