using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;

namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
{
    public class RecipeStepValidationInfo
    {
        #region Constructors

        public RecipeStepValidationInfo(RecipeStep step, Param param, string message)
        {
            Step = step;
            Param = param;
            Message = message;

            RecipeStep.ValidateStepNo(step.StepNo, out var vStepNo);
            StepNo = vStepNo;

            ParamCaption = param?.DisplayName ?? "Unknown";

            if (param is IValueParam vp)
                Value = vp.GetValue();
            else
                Value = "Unknown";
        }

        #endregion

        #region Properties

        public RecipeStep Step { get; }

        public IParam Param { get; }

        public int StepNo { get; }

        public string ParamCaption { get; }

        public object Value { get; }

        public string Message { get; }

        #endregion

        #region Methdos

        public override string ToString()
        {
            return $"[Step{Step.StepNo}][{Param.DisplayName}] {Message}";
        }

        #endregion
    }
}
