using System; using System.Collections.Generic; namespace Apewer.Web { /// public abstract class ApiController : IDisposable { internal ApiApplication Application = null; internal ApiFunction Function = null; private ApiRequest _request = null; private ApiResponse _response = null; private bool _allow = true; /// 获取 API 请求模型。 public virtual ApiRequest Request { get { return _request; } internal set { _request = value; } } /// 获取 API 响应模型。 public virtual ApiResponse Response { get { if (_response == null) _response = new ApiResponse(); return _response; } internal set { _response = value; } } /// 获取或设置初始化方法。 public virtual Action AfterInitialized { get; set; } /// 获取或设置默认功能,在匹配 Function 失败后调用。 public virtual Action DefaultFunction { get; set; } /// 默认允许调用 Function。当存在 Independent 特性时 Invoker 将忽略此值,且不调用 Function。 public virtual bool AllowFunction { get { return _allow; } protected set { _allow = value; } } /// public virtual void Dispose() { } void InvalidFunction() => Response.Error("指定的 Function 无效。"); } }