using System; using DelftTools.Utils.Collections.Generic; namespace DelftTools.Shell.Core.Workflow { /// /// Defines basic activity which can be executed as part of the workflow. /// /// /// Regular workflow for an activity is: Initialize -> Execute -> Finish -> Cleanup. /// Regular workflow for an activity with an error occurring: [Initialize/Execute/Finish] -> ! Exception / Error ! -> Cleanup. /// Regular workflow for an activity being cancelled: [Initialize/Execute/Finish] -> ! Cancel ! -> Cleanup. /// public interface IActivity : IProjectItem /* TODO: wrap it with the ProjectItem instead */ { /// /// Event to be fired when we want to publish changes in . /// event EventHandler ProgressChanged; /// /// Event to be fired on every change. /// event EventHandler StatusChanged; /// /// Activity may depend on other activities. Used within . /// IEventedList DependsOn { get; set; } /// /// Returns current status of the activity (executing, cancelling, etc.) /// ActivityStatus Status { get; } /// /// Text to describe the current progress of the activity. Most often a percentage. /// string ProgressText { get; } /// /// Initializes activity. If initialization step is successful, /// will change to . /// void Initialize(); /// /// Executes activity. Depending on status of the activity execution may need to be repeated. /// void Execute(); /// /// Signal the activity to cancel execution. Activity cancels on next execute. /// /// This method must be implemented as thread-safe. /// void Cancel(); /// /// The activity has finished executing. /// void Finish(); /// /// Cleans all resources required during execution. /// /// This method will always be called, even when an exception occurs. Take /// this into account when implementing this method. void Cleanup(); } }