using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PXP.Crawler.API.Model;

namespace PXP.Crawler.API.Plugins.Operators
{
    public class ValueOperatorNodeBase<T> : Node
    {
        public ValueOperatorNodeBase(Program program)
            : base(program)
        {
        }

        protected internal T cvalue;
        protected internal T result;

        protected virtual internal T ComputeResult()
        {
            return cvalue;
        }

        public override void CreateDesigner()
        {
            base.CreateDesigner();
            designer.Control.BackColor = Color.Teal;
        }
        
        [NodePin(NodePin.NodePinDirection.Input)]
        public T Value
        {
            get
            {
                return cvalue;
            }
            set
            {
                cvalue = value;
                Result = ComputeResult();
            }
        }

        [NodePin(NodePin.NodePinDirection.Output)]
        public T Result
        {
            get
            {
                return result;
            }
            internal set
            {
                result = value;
                NotifyPropertyChange("Result");
            }
        }
    }
}
