127 lines
3.7 KiB
C#
127 lines
3.7 KiB
C#
using Microsoft.AspNetCore.SignalR.Protocol;
|
|
|
|
using Newtonsoft.Json.Serialization;
|
|
using Newtonsoft.Json;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HuanMeng.DotNetCore.Base
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class MessageBox : Exception
|
|
{
|
|
/// <summary>
|
|
/// 基础数据
|
|
/// </summary>
|
|
public BaseResponse<object> BaseResponse { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="code"></param>
|
|
public MessageBox(ResponseCode code)
|
|
{
|
|
BaseResponse = new Base.BaseResponse<object>(code);
|
|
|
|
}
|
|
public MessageBox(BaseResponse<object> baseResponse)
|
|
{
|
|
this.BaseResponse = baseResponse;
|
|
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="code"></param>
|
|
/// <param name="message"></param>
|
|
/// <param name="data"></param>
|
|
public MessageBox(ResponseCode code, string message, object? data = null)
|
|
{
|
|
BaseResponse = new Base.BaseResponse<object>(code, message, data);
|
|
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="code"></param>
|
|
/// <param name="message"></param>
|
|
/// <param name="data"></param>
|
|
public MessageBox(int code, string message, object? data = null)
|
|
{
|
|
BaseResponse = new Base.BaseResponse<object>(code, message, data);
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
/// <param name="data"></param>
|
|
public MessageBox(string message, object? data = null)
|
|
{
|
|
BaseResponse = new Base.BaseResponse<object>(0, message, data);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public BaseResponse<object> ToBaseResponse()
|
|
{
|
|
return BaseResponse;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public override string ToString()
|
|
{
|
|
return BaseResponse.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建错误消息
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static MessageBox ErrorShow(string message) => new(ResponseCode.Error, message);
|
|
|
|
/// <summary>
|
|
/// 创建消息
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static MessageBox Show(string message) => new(message);
|
|
|
|
/// <summary>
|
|
/// 创建消息 输出消息和数据
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
/// <param name="data"></param>
|
|
public static MessageBox Show(string message, object data) => new(message, data);
|
|
|
|
/// <summary>
|
|
/// 创建消息 输出消息和数据
|
|
/// </summary>
|
|
/// <param name="code"></param>
|
|
/// <param name="message"></param>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public static MessageBox Show(int code, string message, object? data = null) => new(code, message, data);
|
|
|
|
/// <summary>
|
|
/// 创建消息 输出消息和数据
|
|
/// </summary>
|
|
/// <param name="code"></param>
|
|
/// <param name="message"></param>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public static MessageBox Show(ResponseCode code, string message, object? data = null) => new(code, message, data);
|
|
}
|
|
}
|