old_flsystem/类库/Api.Framework/Events/WebRequestEvents.cs

72 lines
2.0 KiB
C#

using Microsoft.Owin;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Api.Framework.Events
{
/// <summary>
/// web请求事件
/// </summary>
public class WebRequestEvents : BaseEvents
{
/// <summary>
/// 响应结果
/// </summary>
private WebClient.Result Respose { get; set; }
/// <summary>
/// 发送错误请求
/// </summary>
/// <param name="e">异常</param>
/// <param name="code">错误代码</param>
public void Send(Exception e, int code = -1)
{
Send(e.Message, code);
}
/// <summary>
/// 发送正确请求
/// </summary>
/// <param name="message">请求内容</param>
/// <param name="code">正确代码</param>
public void Send(object message, int code = 0)
{
Respose.Message = message;
Respose.Code = code;
this.Cancel = true;
}
/// <summary>
/// 提交的参数 包含:GET POST 合集
/// </summary>
public Dictionary<string, string> Param { get; private set; }
/// <summary>
/// 上下文
/// </summary>
public IOwinContext Context { get; private set; }
/// <summary>
/// cookies
/// </summary>
public NameValueCollection Cookies { get; private set; }
/// <summary>
/// 构造方法
/// </summary>
/// <param name="context">上下文</param>
/// <param name="Param">提交的参数 包含:GET POST 合集</param>
/// <param name="Respose">响应的对象</param>
public WebRequestEvents(IOwinContext context, Dictionary<string, string> Param, WebClient.Result Respose)
{
this.Context = context;
this.Param = Param;
this.Respose = Respose;
}
}
}