using System;
using System.Collections.Generic;
using System.Text;

namespace FormulaEditor
{
    /// <summary>
    /// Detector of array unary operation
    /// </summary>
    public class ArrayOperationDetector : IOperationDetector
    {

        #region Fields
        private IOperationDetector detector;
        #endregion

        public ArrayOperationDetector(IOperationDetector detector)
        {
            this.detector = detector;
        }

        #region IOperationDetector Members

        public IOperationAcceptor Detect(MathSymbol s)
        {
            IOperationAcceptor acc = detector.Detect(s);
            if (acc == null)
            {
                return null;
            }
            if (acc is IMultiVariableOperationAcceptor)
            {
                return new MultiVariableArrayOperationAcceptor(acc as IMultiVariableOperationAcceptor);
            }
            return new ArrayOperationAcceptor(acc);
        }

        #endregion
    }
}
