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

namespace FormulaEditor
{

    /// <summary>
    /// Array operation acceptor with array
    /// </summary>
    public class ArrayOperationAcceptor : IOperationAcceptor
    {
        #region Fields

        /// <summary>
        /// Operation acceptor
        /// </summary>
        private IOperationAcceptor acceptor;


        #endregion

        #region Constructors
        public ArrayOperationAcceptor(IOperationAcceptor acceptor)
        {
            this.acceptor = acceptor;
        }
        #endregion

        #region IOperationAcceptor Members

        public IObjectOperation Accept(object type)
        {
            if (type is ArrayReturnType)
            {
                ArrayReturnType a = type as ArrayReturnType;
                IObjectOperation op = acceptor.Accept(a.ElementType);
                if (op == null)
                {
                    return null;
                }
                return new ArrayOperation(op, new object[] { type });
            }
            return acceptor.Accept(type);
        }

        #endregion

    }

}
