using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using JWH.DATA;

namespace DDUtilityApp.DATA
{

    public class Workflow : DataTableBase
    {

        /// <summary>
        /// Model ID
        /// </summary>
        public string ModelID { get; set; }

        /// <summary>
        /// File Name
        /// </summary>
        public string FileName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string DisplayName { get; set; }

        /// <summary>
        /// Library Name
        /// </summary>
        public string LibraryName { get; set; }

        /// <summary>
        /// Class Name
        /// </summary>
        public string ClassName { get; set; }

        /// <summary>
        /// Method Name
        /// </summary>
        public string MethodName { get; set; }

        /// <summary>
        /// Argument collection
        /// </summary>
        public List<Argument> Arguments { get; set; } = new List<Argument>();

        [ReadOnly(true)]
        public string ArgumentsText
        {
            get { return this.GetArgumentsText(); }
        }


        public Workflow()
        {
        }

        public Workflow(string modelID, string fileName)
        {
            this.ModelID = modelID;
            this.FileName = fileName;
        }

        private string GetArgumentsText()
        {
            StringBuilder sb = new StringBuilder();
            foreach (Argument arg in this.Arguments)
            {
                if (sb.Length > 0) sb.Append(", ");
                sb.Append(arg.ToString());
            }

            return sb.ToString();
        }

    }

    public class Argument
    {

        public string Name { get; set; }

        public string Type { get; set; }

        public string Value { get; set; }


        public Argument()
        {
        }

        public Argument( string name, string type, string value)
        {
            this.Name = name;
            this.Type = type;
            this.Value = value;
        }

        public override string ToString()
        {
            return $"Name = {this.Name}, type = {this.Type}, Value = {this.Value}";
        }

    }

}
