Changeset 2876 for trunk/sources
- Timestamp:
- 02/26/10 16:38:19 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs
r1823 r2876 98 98 Assembly defaultAssembly = Assembly.GetExecutingAssembly(); 99 99 DiscoverFrom(defaultAssembly); 100 foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) 101 if (a != defaultAssembly) 102 DiscoverFrom(a); 100 try { 101 foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) 102 if (a != defaultAssembly) 103 DiscoverFrom(a); 104 } catch (AppDomainUnloadedException x) { 105 Logger.Warn("could not get list of assemblies, AppDomain has already been unloaded", x); 106 } 103 107 SortCompositeSerializers(); 104 108 } … … 115 119 116 120 protected void DiscoverFrom(Assembly a) { 117 foreach (Type t in a.GetTypes()) { 118 if (t.GetInterface(typeof(IPrimitiveSerializer).FullName) != null) { 119 try { 120 IPrimitiveSerializer primitiveSerializer = 121 (IPrimitiveSerializer)Activator.CreateInstance(t, true); 122 if (!PrimitiveSerializers.ContainsKey(primitiveSerializer.SerialDataType)) { 123 PrimitiveSerializers.Add(primitiveSerializer.SerialDataType, new List<IPrimitiveSerializer>()); 121 try { 122 foreach (Type t in a.GetTypes()) { 123 if (t.GetInterface(typeof(IPrimitiveSerializer).FullName) != null) { 124 try { 125 IPrimitiveSerializer primitiveSerializer = 126 (IPrimitiveSerializer)Activator.CreateInstance(t, true); 127 if (!PrimitiveSerializers.ContainsKey(primitiveSerializer.SerialDataType)) { 128 PrimitiveSerializers.Add(primitiveSerializer.SerialDataType, new List<IPrimitiveSerializer>()); 129 } 130 PrimitiveSerializers[primitiveSerializer.SerialDataType].Add(primitiveSerializer); 131 Logger.Debug(String.Format("discovered primitive serializer {0} ({1} -> {2})", 132 t.VersionInvariantName(), 133 primitiveSerializer.SourceType.AssemblyQualifiedName, 134 primitiveSerializer.SerialDataType.AssemblyQualifiedName)); 135 } catch (MissingMethodException e) { 136 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 137 } catch (ArgumentException e) { 138 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 124 139 } 125 PrimitiveSerializers[primitiveSerializer.SerialDataType].Add(primitiveSerializer); 126 Logger.Debug(String.Format("discovered primitive serializer {0} ({1} -> {2})", 127 t.VersionInvariantName(), 128 primitiveSerializer.SourceType.AssemblyQualifiedName, 129 primitiveSerializer.SerialDataType.AssemblyQualifiedName)); 130 } catch (MissingMethodException e) { 131 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 132 } catch (ArgumentException e) { 133 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 140 } 141 if (t.GetInterface(typeof(ICompositeSerializer).FullName) != null) { 142 try { 143 CompositeSerializers.Add((ICompositeSerializer)Activator.CreateInstance(t, true)); 144 Logger.Debug("discovered composite serializer " + t.AssemblyQualifiedName); 145 } catch (MissingMethodException e) { 146 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 147 } catch (ArgumentException e) { 148 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 149 } 150 } 151 if (t.GetInterface(typeof(IFormat).FullName) != null) { 152 try { 153 IFormat format = (IFormat)Activator.CreateInstance(t, true); 154 Formats.Add(format); 155 Logger.Debug(String.Format("discovered format {0} ({2}) with serial data {1}.", 156 format.Name, 157 format.SerialDataType, 158 t.AssemblyQualifiedName)); 159 } catch (MissingMethodException e) { 160 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 161 } catch (ArgumentException e) { 162 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 163 } 134 164 } 135 165 } 136 if (t.GetInterface(typeof(ICompositeSerializer).FullName) != null) { 137 try { 138 CompositeSerializers.Add((ICompositeSerializer)Activator.CreateInstance(t, true)); 139 Logger.Debug("discovered composite serializer " + t.AssemblyQualifiedName); 140 } catch (MissingMethodException e) { 141 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 142 } catch (ArgumentException e) { 143 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 144 } 145 } 146 if (t.GetInterface(typeof(IFormat).FullName) != null) { 147 try { 148 IFormat format = (IFormat)Activator.CreateInstance(t, true); 149 Formats.Add(format); 150 Logger.Debug(String.Format("discovered format {0} ({2}) with serial data {1}.", 151 format.Name, 152 format.SerialDataType, 153 t.AssemblyQualifiedName)); 154 } catch (MissingMethodException e) { 155 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 156 } catch (ArgumentException e) { 157 Logger.Warn("Could not instantiate " + t.AssemblyQualifiedName, e); 158 } 159 } 166 } catch (ReflectionTypeLoadException e) { 167 Logger.Warn("could not analyse assembly: " + a.FullName, e); 160 168 } 161 169 }
Note: See TracChangeset
for help on using the changeset viewer.