Changeset 5131
- Timestamp:
- 12/17/10 16:22:57 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/DefaultApplicationManager.cs
r4482 r5131 158 158 /// <returns>Enumerable of the created instances.</returns> 159 159 internal static IEnumerable<T> GetInstances<T>(IPluginDescription plugin) where T : class { 160 return from t in GetTypes(typeof(T), plugin, true) 161 select (T)Activator.CreateInstance(t); 160 List<T> instances = new List<T>(); 161 foreach (Type t in GetTypes(typeof(T), plugin, true)) { 162 T instance = null; 163 try { instance = (T)Activator.CreateInstance(t); } 164 catch { } 165 if (instance != null) instances.Add(instance); 166 } 167 return instances; 162 168 } 163 169 /// <summary> … … 168 174 /// <returns>Enumerable of the created instances.</returns> 169 175 private static IEnumerable<T> GetInstances<T>(Assembly asm) where T : class { 170 return from t in GetTypes(typeof(T), asm, true) 171 select (T)Activator.CreateInstance(t); 176 List<T> instances = new List<T>(); 177 foreach (Type t in GetTypes(typeof(T), asm, true)) { 178 T instance = null; 179 try { instance = (T)Activator.CreateInstance(t); } 180 catch { } 181 if (instance != null) instances.Add(instance); 182 } 183 return instances; 172 184 } 173 185 /// <summary> … … 187 199 /// <returns>Enumerable of the created instances.</returns> 188 200 internal static IEnumerable<object> GetInstances(Type type) { 189 return (from t in GetTypes(type, true) 190 select Activator.CreateInstance(t)).ToList(); 201 List<object> instances = new List<object>(); 202 foreach (Type t in GetTypes(type, true)) { 203 object instance = null; 204 try { instance = Activator.CreateInstance(t); } 205 catch { } 206 if (instance != null) instances.Add(instance); 207 } 208 return instances; 191 209 } 192 210 -
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/LightweightApplicationManager.cs
r4482 r5131 72 72 /// <returns>Enumerable of the created instances.</returns> 73 73 public IEnumerable<object> GetInstances(Type type) { 74 return from t in GetTypes(type, true) 75 select Activator.CreateInstance(t); 74 List<object> instances = new List<object>(); 75 foreach (Type t in GetTypes(type, true)) { 76 object instance = null; 77 try { instance = Activator.CreateInstance(t); } 78 catch { } 79 if (instance != null) instances.Add(instance); 80 } 81 return instances; 76 82 } 77 83
Note: See TracChangeset
for help on using the changeset viewer.