Changeset 10150 for trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks
- Timestamp:
- 11/22/13 14:23:56 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks/EngineTask.cs
r10130 r10150 60 60 } 61 61 62 public EngineTask(IEngine engine) { 63 this.Item = engine; 64 } 62 public EngineTask(IEngine engine) : base(engine) { } 65 63 66 64 [StorableConstructor] -
trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks/ItemTask.cs
r10130 r10150 22 22 using System; 23 23 using System.Drawing; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Hive; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.PluginInfrastructure; 28 30 29 31 namespace HeuristicLab.Clients.Hive { … … 76 78 this.Item = cloner.Clone(original.Item); 77 79 } 80 public ItemTask(IItem item) { 81 Item = item; 82 } 78 83 79 84 [StorableHook(HookType.AfterDeserialization)] … … 216 221 return Name; 217 222 } 223 224 #region Helpers 225 public static bool IsTypeSupported(Type itemType) { 226 var supportedHiveTaskTypes = ApplicationManager.Manager.GetTypes(typeof(ItemTask)) 227 .Select(t => t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)).PropertyType); 228 return supportedHiveTaskTypes.Any(x => x.IsAssignableFrom(itemType)); 229 } 230 231 public static Type GetHiveTaskType(Type itemType) { 232 if (!IsTypeSupported(itemType)) throw new Exception("Item " + itemType + " is not supported for Hive."); 233 234 var typeHiveTaskMap = ApplicationManager.Manager.GetTypes(typeof(ItemTask)) 235 .Select(t => new Tuple<Type, Type>(t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)).PropertyType, t)); 236 237 return typeHiveTaskMap.Single(x => x.Item1.IsAssignableFrom(itemType)).Item2; 238 } 239 240 public static ItemTask GetItemTaskForItem(IItem item) { 241 Type itemType = item.GetType(); 242 Type hiveTaskType = GetHiveTaskType(itemType); 243 return Activator.CreateInstance(hiveTaskType, new object[] { item }) as ItemTask; 244 } 245 #endregion 218 246 } 219 247 } -
trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks/OptimizerTask.cs
r10130 r10150 50 50 } 51 51 52 public OptimizerTask(IOptimizer optimizer) {53 this.Item = optimizer;52 public OptimizerTask(IOptimizer optimizer) 53 : base(optimizer) { 54 54 55 55 if (optimizer is Experiment) {
Note: See TracChangeset
for help on using the changeset viewer.