protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey) { string taskType = reader.GetAttribute("type"); if (string.IsNullOrEmpty(taskType)) { taskType = TaskType.command.ToString(); } TaskType type = (TaskType)Enum.Parse(typeof(TaskType), taskType); switch (type) { case TaskType.snapshot: _config = new SnapshotTaskConfig(_when); break; case TaskType.virtualmachine: _config = new VirtualMachineTaskConfig(_when); break; case TaskType.command: default: _config = new CommandTaskConfig(_when); break; } _config.ProxyDeserializeElement(reader, serializeCollectionKey); }
/// <summary> /// Execute during additional sequence. /// </summary> public override List <XmlResult> ExecuteSequence(SequenceWhen when) { List <XmlResult> results = new List <XmlResult>(); foreach (TasksConfig executes in _configs) { foreach (TaskConfigProxy proxy in executes) { TaskConfigInstance execute = proxy.Instance; if (execute.ExecuteCommandWhen == when) { if (execute is CommandTaskConfig) { results.Add(Execute((CommandTaskConfig)execute)); } else if (execute is SnapshotTaskConfig) { results.Add(Execute((SnapshotTaskConfig)execute)); } else if (execute is VirtualMachineTaskConfig) { results.Add(Execute((VirtualMachineTaskConfig)execute)); } else { throw new NotImplementedException(string.Format("Unsupported task type: {0}", execute.GetType().Name)); } } } } return(results); }
public void Add(TaskConfigInstance value) { BaseAdd(new TaskConfigProxy(value)); }
public TaskConfigProxy(TaskConfigInstance instance) { _when = instance.ExecuteCommandWhen; _config = instance; }
protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey) { string taskType = reader.GetAttribute("type"); if (string.IsNullOrEmpty(taskType)) taskType = TaskType.command.ToString(); TaskType type = (TaskType)Enum.Parse(typeof(TaskType), taskType); switch (type) { case TaskType.snapshot: _config = new SnapshotTaskConfig(_when); break; case TaskType.virtualmachine: _config = new VirtualMachineTaskConfig(_when); break; case TaskType.command: default: _config = new CommandTaskConfig(_when); break; } _config.ProxyDeserializeElement(reader, serializeCollectionKey); }