/// <summary> /// This is the generic exception wrapper. /// </summary> /// <param name="action">The action to wrap.</param> /// <param name="title">The section title.</param> /// <param name="type">The action type, i.e. starting or stopping.</param> internal virtual void EventGeneric(Action action, string title, MicroserviceComponentStatusChangeAction type) { var args = new MicroserviceStatusEventArgs(type, title); try { ComponentStatusChange?.Invoke(mService, args); action(); args.State = MicroserviceComponentStatusChangeState.Completed; ComponentStatusChange?.Invoke(mService, args); } catch (Exception ex) { args.Ex = new MicroserviceStatusChangeException(title, ex); args.State = MicroserviceComponentStatusChangeState.Failed; ComponentStatusChange?.Invoke(mService, args); throw args.Ex; } }
/// <summary> /// Initializes a new instance of the <see cref="MicroserviceStatusEventArgs"/> class. /// </summary> /// <param name="status">The status.</param> /// <param name="title">The title.</param> public MicroserviceStatusEventArgs(MicroserviceComponentStatusChangeAction status, string title) { Status = status; Title = title; }