Jeffery Richter’s Exception<TExceptionArgs>

using System;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace GenericException
{
    [Serializable]
    public sealed class Exception<TExceptionArgs> : Exception, ISerializable
        where TExceptionArgs : ExceptionArgs
    {
        private const String CArgs = "Args";
        private readonly TExceptionArgs _args;

        public TExceptionArgs Args { get { return _args; } }


        public Exception(String message = null, Exception innerException = null)
            : this(null, message, innerException) { }

        public Exception(TExceptionArgs args, String message = null, Exception innerException = null)
            : base(message, innerException)
        {
            _args = args;
        }


        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
        private Exception(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _args = (TExceptionArgs)info.GetValue(CArgs, typeof(TExceptionArgs));
        }

        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue(CArgs, _args);
            base.GetObjectData(info, context);
        }

        public override string Message
        {
            get
            {
                String baseMessage = base.Message;
                return _args == null ? baseMessage : baseMessage + "(" + _args.Message + ")";
            }
        }

        public override bool Equals(object obj)
        {
            Exception<TExceptionArgs> other = obj as Exception<TExceptionArgs>;
            if (other==null)
            {
                return false;
            }

            return Object.Equals(_args, other.Args) && base.Equals(obj);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }

    [Serializable]
    public abstract class ExceptionArgs
    {
        public virtual String Message { get { return String.Empty; } }
    }
}

转载于:https://www.cnblogs.com/fast-michael/archive/2012/08/22/2651693.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<!--index.wxml--> <view class="top-box"> <view>Hi</view> <view class="next-text">欢迎使用!</view> </view> <!-- 登录、注册 --> <view class="center-box"> <view class="nav"> <view class="left {{current==1?'select':''}}" bindtap="click" data-code="1"> <text>登录</text> </view> <view class="right {{current==0?'select':''}}" bindtap="click" data-code="0"> <text>注册</text> </view> </view> <!-- 登录 --> <view class="input-box" hidden="{{current==0}}"> <view class="wei-input"> <icon type="waiting" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入手机号/登录名"/> </view> <view class="wei-input"> <icon type="success" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入登录密码"/> </view> <view class="forget"> <text>忘记密码?</text> </view> </view> <!-- 注册 --> <view class="input-box" hidden="{{current==1}}"> <view class="wei-input"> <icon type="waiting" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入手机号"/> </view> <view class="wei-input"> <icon type="waiting" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入6位验证码"/> <text class="input-code" bindtap="getCode">{{codeText}}</text> </view> <view class="wei-input"> <icon type="success" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入密码"/> </view> <view class="wei-input"> <icon type="success" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请确认密码"/> </view> </view> <view class="sumbit-btn"> <button class="button" style="background-color: #33ccff;font-size: 30rpx;" type="primary">立即{{current==1?'登录':'注册'}}</button> </view> </view> <!-- 重影 --> <view class="shadow shadow-1"></view><view class="shadow shadow-2"></view> <!-- 说明 --> <view class="bottom-box"> demo·开源·点赞·收藏·打赏·Jeffery~ </view>这段代码可以点击注册按钮跳转么
05-24

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值