| 
						
						
							
								
							
						
						
					 | 
					@ -438,13 +438,13 @@ namespace Apewer.Web | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        #region ApiController
 | 
					 | 
					 | 
					        #region ApiController
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        /// <summary>设置控制器属性。</summary>
 | 
					 | 
					 | 
					        /// <summary>设置控制器的 <see cref="ApiController.Context" /> 属性。</summary>
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        public static void SetProperties(ApiController controller, ApiRequest request, ApiResponse response, ApiOptions options) | 
					 | 
					 | 
					        /// <exception cref="ArgumentNullException" />
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        public static void SetContext(ApiController controller, ApiContext context) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        { | 
					 | 
					 | 
					        { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if (controller == null) return; | 
					 | 
					 | 
					            if (controller == null) throw new ArgumentNullException(nameof(controller)); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            controller.Request = request; | 
					 | 
					 | 
					            if (context == null) throw new ArgumentNullException(nameof(context)); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            controller.Response = response; | 
					 | 
					 | 
					            controller._context = context; | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					            controller._options = options; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        /// <summary>获取由控制器构造函数指定的初始化程序。</summary>
 | 
					 | 
					 | 
					        /// <summary>获取由控制器构造函数指定的初始化程序。</summary>
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -453,9 +453,6 @@ namespace Apewer.Web | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        /// <summary>获取由控制器构造函数指定的默认程序。</summary>
 | 
					 | 
					 | 
					        /// <summary>获取由控制器构造函数指定的默认程序。</summary>
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        public static Action<ApiController> GetDefault(this ApiController controller) => controller == null ? null : controller._default; | 
					 | 
					 | 
					        public static Action<ApiController> GetDefault(this ApiController controller) => controller == null ? null : controller._default; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        /// <summary>获取选项。</summary>
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        public static ApiOptions GetOptions(this ApiController controller) => controller == null ? null : controller._options; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        /// <summary>以 POST 转移请求到其它 URL。</summary>
 | 
					 | 
					 | 
					        /// <summary>以 POST 转移请求到其它 URL。</summary>
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        private static string Transfer(ApiController controller, string url, string application = null, string function = null) | 
					 | 
					 | 
					        private static string Transfer(ApiController controller, string url, string application = null, string function = null) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        { | 
					 | 
					 | 
					        { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -499,15 +496,14 @@ namespace Apewer.Web | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            return null; | 
					 | 
					 | 
					            return null; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        /// <summary>创建指定类型的控制器,并引用当前控制器的 Request 和 Response。</summary>
 | 
					 | 
					 | 
					        /// <summary>创建指定类型的控制器,并引用参照控制器的 Context。</summary>
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        public static T Create<T>(this ApiController current) where T : ApiController, new() | 
					 | 
					 | 
					        /// <exception cref="ArgumentNullException" />
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        public static T Create<T>(this ApiController reference) where T : ApiController, new() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        { | 
					 | 
					 | 
					        { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (reference == null) throw new ArgumentNullException(nameof(reference)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            var controller = new T(); | 
					 | 
					 | 
					            var controller = new T(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if (current != null) | 
					 | 
					 | 
					            controller._context = reference.Context; | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					            { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                controller.Request = current.Request; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                controller.Response = current.Response; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            return controller; | 
					 | 
					 | 
					            return controller; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -515,7 +511,7 @@ namespace Apewer.Web | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        public static void UseDefault(this ApiController current) | 
					 | 
					 | 
					        public static void UseDefault(this ApiController current) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        { | 
					 | 
					 | 
					        { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            if (current == null) return; | 
					 | 
					 | 
					            if (current == null) return; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            var options = GetOptions(current); | 
					 | 
					 | 
					            var options = current._context?.Options; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            if (options == null) return; | 
					 | 
					 | 
					            if (options == null) return; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            var type = options.Default; | 
					 | 
					 | 
					            var type = options.Default; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            if (type == null) return; | 
					 | 
					 | 
					            if (type == null) return; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -523,7 +519,7 @@ namespace Apewer.Web | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            try | 
					 | 
					 | 
					            try | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            { | 
					 | 
					 | 
					            { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                controller = (ApiController)Activator.CreateInstance(type); | 
					 | 
					 | 
					                controller = (ApiController)Activator.CreateInstance(type); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                SetProperties(controller, current.Request, current.Response, options); | 
					 | 
					 | 
					                SetContext(controller, current.Context); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            catch | 
					 | 
					 | 
					            catch | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            { | 
					 | 
					 | 
					            { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |