Class ApiOut
Namespace: Tool.Web.Api
Assembly: Tool.Net.dll
系统默认 Api输出结果 抽象类,用于普通返回值,特殊返回值建议您自己实现。
public abstract class ApiOut : IApiOutInheritance
Derived
FileOut, JsonOut, RedirectOut, ViewOut, WriteOut
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Extension Methods
ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)
Remarks
代码由逆血提供支持
Constructors
ApiOut()
无参构造
protected ApiOut()Properties
ContentType
输出类型
public abstract string ContentType { get; set; }Property Value
StatusCode
HTTP 返回 Code
public abstract int StatusCode { get; set; }Property Value
Methods
EventStream(Func<EventStream, Task>, int)
SSE服务器事件流
public static EventStreamOut EventStream(Func<EventStream, Task> func, int retry = 3000)Parameters
func Func<EventStream, Task>
流任务
retry int
超时重连时间
Returns
输出对象
EventStreamAsync(Func<EventStream, Task>, int)
SSE服务器事件流
public static Task<EventStreamOut> EventStreamAsync(Func<EventStream, Task> func, int retry = 3000)Parameters
func Func<EventStream, Task>
流任务
retry int
超时重连时间
Returns
输出对象
ExecuteOutAsync(AshxRouteData)
系统回调,用于完成该请求任务的输出
public abstract Task ExecuteOutAsync(AshxRouteData ashxRoute)Parameters
ashxRoute AshxRouteData
包含所有有效信息
Returns
异步任务
File(string, Stream)
向客户端返回下载的资源文件
public static FileOut File(string name, Stream fileStream)Parameters
name string
文件名称
fileStream Stream
文件流对象
Returns
输出对象
File(string, byte[])
向客户端返回下载的资源文件
public static FileOut File(string name, byte[] bytes)Parameters
name string
文件名称
bytes byte[]
文件字节流
Returns
输出对象
FileAsync(string, Stream)
异步向客户端返回下载的资源文件
public static Task<FileOut> FileAsync(string name, Stream fileStream)Parameters
name string
文件名称
fileStream Stream
文件流对象
Returns
输出对象
FileAsync(string, byte[])
异步向客户端返回下载的资源文件
public static Task<FileOut> FileAsync(string name, byte[] bytes)Parameters
name string
文件名称
bytes byte[]
文件字节流
Returns
输出对象
Json(object)
向客户端返回JSON数据
public static JsonOut Json(object obj)Parameters
obj object
源数据
Returns
输出对象
Json(object, JsonSerializerOptions)
向客户端返回JSON数据
public static JsonOut Json(object obj, JsonSerializerOptions JsonOptions)Parameters
obj object
源数据
JsonOptions JsonSerializerOptions
Json 转换条件
Returns
输出对象
JsonAsync(object)
异步向客户端返回JSON数据
public static Task<JsonOut> JsonAsync(object obj)Parameters
obj object
源数据
Returns
输出对象
JsonAsync(object, JsonSerializerOptions)
异步向客户端返回JSON数据
public static Task<JsonOut> JsonAsync(object obj, JsonSerializerOptions JsonOptions)Parameters
obj object
源数据
JsonOptions JsonSerializerOptions
Json 转换条件
Returns
输出对象
NoContent()
无输出结果
public static NoContentOut NoContent()Returns
输出对象
NoContentAsync()
无输出结果
public static Task<NoContentOut> NoContentAsync()Returns
输出对象
PathView(string)
向客户端返回页面
public static ViewOut PathView(string pathName)Parameters
pathName string
源数据(是wwwroot文件夹下面的相对路径),不支持绝对路径 的文件夹名称 支持多重文件 不能包含文件
Returns
输出对象
PathViewAsync(string)
异步向客户端返回页面
public static Task<ViewOut> PathViewAsync(string pathName)Parameters
pathName string
源数据(是wwwroot文件夹下面的相对路径),不支持绝对路径 的文件夹名称 支持多重文件 不能包含文件
Returns
输出对象
Redirect(string)
向客户端返回重定向的URl
public static RedirectOut Redirect(string url)Parameters
url string
跳转的URL
Returns
输出对象
RedirectAsync(string)
异步向客户端返回重定向的URl
public static Task<RedirectOut> RedirectAsync(string url)Parameters
url string
跳转的URL
Returns
输出对象
View()
向客户端返回页面(默认模式路径:wwwroot文件夹下,加上控制器名和接口名:/Views/Api/Get.html)
public static ViewOut View()Returns
输出对象
View(string)
向客户端返回页面
public static ViewOut View(string viewName)Parameters
viewName string
源数据(是wwwroot文件夹下面的相对路径),不支持绝对路径
Returns
输出对象
ViewAsync()
异步向客户端返回页面(默认模式路径:ApiView文件夹下,加上控制器名和接口名:/Views/Api/Get.html)
public static Task<ViewOut> ViewAsync()Returns
输出对象
ViewAsync(string)
异步向客户端返回页面
public static Task<ViewOut> ViewAsync(string viewName)Parameters
viewName string
源数据(是wwwroot文件夹下面的相对路径),不支持绝对路径
Returns
输出对象
Write(object)
向客户端返回Text数据
public static WriteOut Write(object obj)Parameters
obj object
源数据
Returns
输出对象
WriteAsync(object)
异步向客户端返回Text数据
public static Task<WriteOut> WriteAsync(object obj)Parameters
obj object
源数据
Returns
输出对象