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
{
///
///
///
public class MessageBox : Exception
{
///
/// 基础数据
///
public BaseResponse BaseResponse { get; set; }
///
///
///
///
public MessageBox(ResponseCode code)
{
BaseResponse = new Base.BaseResponse(code);
}
public MessageBox(BaseResponse baseResponse)
{
this.BaseResponse = baseResponse;
}
///
///
///
///
///
///
public MessageBox(ResponseCode code, string message, object? data = null)
{
BaseResponse = new Base.BaseResponse(code, message, data);
}
///
///
///
///
///
///
public MessageBox(int code, string message, object? data = null)
{
BaseResponse = new Base.BaseResponse(code, message, data);
}
///
///
///
///
///
public MessageBox(string message, object? data = null)
{
BaseResponse = new Base.BaseResponse(0, message, data);
}
///
///
///
///
public BaseResponse ToBaseResponse()
{
return BaseResponse;
}
///
///
///
///
public override string ToString()
{
return BaseResponse.ToString();
}
///
/// 创建错误消息
///
///
///
public static MessageBox ErrorShow(string message) => new(ResponseCode.Error, message);
///
/// 创建消息
///
///
///
public static MessageBox Show(string message) => new(message);
///
/// 创建消息 输出消息和数据
///
///
///
public static MessageBox Show(string message, object data) => new(message, data);
///
/// 创建消息 输出消息和数据
///
///
///
///
///
public static MessageBox Show(int code, string message, object? data = null) => new(code, message, data);
///
/// 创建消息 输出消息和数据
///
///
///
///
///
public static MessageBox Show(ResponseCode code, string message, object? data = null) => new(code, message, data);
}
}