zoukankan      html  css  js  c++  java
  • C# 封装返回类

    using System;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;
    using System.Text;
    
    namespace TXR.Base
    {
        public class CommonResult<TValue>
        {
            public CommonResult(TValue value)
            {
                this.Value = value;
            }
    
            public CommonResult(WarnResult value)
            {
                this.WarnResult = value;
            }
    
            [CompilerGenerated]
            public TValue Value { get; }
    
            [CompilerGenerated]
            public WarnResult WarnResult { get; }
    
            public static implicit operator CommonResult<TValue>(TValue value)
            {
                return new CommonResult<TValue>(value);
            }
    
            public static implicit operator CommonResult<TValue>(WarnResult value)
            {
                return new CommonResult<TValue>(value);
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace TXR.Base
    {
        public class WarnResult : ApiMessageErrorModel
        {
            public WarnResult(string msg)
            {
                base.Message = msg;
            }
        }
    }

     第二版

    using System.Runtime.CompilerServices;
    
    namespace WordInsertImg
    {
        public class CommonResult<TValue>
        {
            public CommonResult(TValue value)
            {
                this.Value = value;
            }
    
            public CommonResult(WarnResult value)
            {
                this.WarnResult = value;
            }
    
            [CompilerGenerated]
            public TValue Value { get; }
    
            [CompilerGenerated]
            public WarnResult WarnResult { get; }
    
            public static implicit operator CommonResult<TValue>(TValue value)
            {
                return new CommonResult<TValue>(value);
            }
    
            public static implicit operator CommonResult<TValue>(WarnResult value)
            {
                return new CommonResult<TValue>(value);
            }
        }
    
        public class WarnResult : ApiMessageErrorModel
        {
            public WarnResult(string msg)
            {
                base.Message = msg;
            }
        }
        public class ApiMessageErrorModel
        {
            public ApiMessageErrorModel()
            {
                this.Success = 0;
            }
    
            public ApiMessageErrorModel(string errorCode, string errorMsg)
            {
                this.Success = 0;
                this.Code = errorCode;
                this.Message = errorMsg;
            }
            public string Code { get; set; }
            public string Message { get; set; }
            public int Success { get; set; }
    
        }
    }
  • 相关阅读:
    贪婪大陆
    色板游戏
    11/29 NOIP 模拟赛
    USACO4.4 重叠的图像 Frame Up
    CSP2020 题解
    NOIP前板子复习
    关于我
    【洛谷】【搜索+字符串】
    【洛谷】【动态规划/01背包】P2925 [USACO08DEC]干草出售Hay For Sale
    【洛谷】【二分查找】P1102 A−B数对
  • 原文地址:https://www.cnblogs.com/blogs2014/p/10831262.html
Copyright © 2011-2022 走看看