Changeset 2679 for trunk/sources/HeuristicLab.Operators.Programmable
- Timestamp:
- 01/25/10 10:50:50 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators.Programmable/3.2/ProgrammableOperator.cs
r2678 r2679 66 66 private object syncRoot = new object(); 67 67 68 private static object initLock = new object(); 69 private static Dictionary<string, List<Assembly>> defaultPluginDict; 70 private static Dictionary<Assembly, bool> defaultAssemblyDict; 71 68 72 public readonly Dictionary<string, List<Assembly>> Plugins; 69 73 … … 130 134 131 135 #region Construction & Initialization 132 136 133 137 public ProgrammableOperator() { 134 138 code = ""; 135 139 description = "An operator that can be programmed for arbitrary needs."; 136 140 executeMethod = null; 137 Assemblies = DiscoverAssemblies(); 141 ProgrammableOperator.StaticInitialize(); 142 Assemblies = defaultAssemblyDict; 143 Plugins = defaultPluginDict; 138 144 namespaces = new HashSet<string>(DiscoverNamespaces()); 139 Plugins = GroupAssemblies(); 140 } 141 142 private Dictionary<string, List<Assembly>> GroupAssemblies() { 145 } 146 147 private static void StaticInitialize() { 148 lock (initLock) { 149 if (defaultPluginDict != null || defaultAssemblyDict != null) return; 150 defaultAssemblyDict = DiscoverAssemblies(); 151 defaultPluginDict = GroupAssemblies(defaultAssemblyDict.Keys); 152 } 153 } 154 155 private static Dictionary<string, List<Assembly>> GroupAssemblies(IEnumerable<Assembly> assemblies) { 143 156 var plugins = new Dictionary<string, List<Assembly>>(); 144 var assemblyNames = Assemblies.ToDictionary(a => a.Key.Location, a => a.Key);157 var locationTable = assemblies.ToDictionary(a => a.Location, a => a); 145 158 foreach (var plugin in ApplicationManager.Manager.Plugins) { 146 159 var aList = new List<Assembly>(); 147 160 foreach (var aName in plugin.Assemblies) { 148 161 Assembly a; 149 assemblyNames.TryGetValue(aName, out a);162 locationTable.TryGetValue(aName, out a); 150 163 if (a != null) { 151 164 aList.Add(a); 152 assemblyNames.Remove(aName);165 locationTable.Remove(aName); 153 166 } 154 167 } 155 168 plugins[plugin.Name] = aList; 156 169 } 157 plugins["other"] = assemblyNames.Values.ToList();170 plugins["other"] = locationTable.Values.ToList(); 158 171 return plugins; 159 172 }
Note: See TracChangeset
for help on using the changeset viewer.