using System;
using System.Collections.Generic;

namespace Apewer.Web
{

    /// <summary></summary>
    public abstract class ApiController : IDisposable
    {

        private ApiRequest _request = null;
        private ApiResponse _response = null;
        private bool _allow = true;

        /// <summary></summary>
        public virtual ApiRequest Request
        {
            get { return _request; }
            internal set { _request = value; }
        }

        /// <summary></summary>
        public virtual ApiResponse Response
        {
            get
            {
                if (_response == null) _response = new ApiResponse();
                return _response;
            }
            internal set { _response = value; }
        }

        /// <summary></summary>
        public virtual Action AfterInitialized { get; set; }

        /// <summary>默认允许调用 Function。当存在 Independent 特性时 Invoker 将忽略此值,且不调用 Function。</summary>
        public virtual bool AllowFunction
        {
            get { return _allow; }
            protected set { _allow = value; }
        }

#if NETFX

        /// <summary>System.Web.HttpContext</summary>
        public virtual System.Web.HttpContext Context { get; internal set; }

#endif

#if NETCORE

        /// <summary>Microsoft.AspNetCore.Http.HttpContext</summary>
        public virtual Microsoft.AspNetCore.Http.HttpContext Context { get; internal set; }

#endif

        /// <summary></summary>
        public virtual void Dispose() { }

    }

}