class InvalidOperationException<T> : InvalidOperationException where T : Command { public InvalidOperationException(string message) : base(message " /> 2018av在线,欧美色另类天堂2015,青草影视电视剧免费播放在线观看

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

.NET 擴展實現(xiàn)代碼

class Command
{
public virtual void Execute() { }
}

class InvalidOperationException<T> : InvalidOperationException
where T : Command
{
public InvalidOperationException(string message) : base(message) { }
// some specific information about
// the command type T that threw this exception
}

static class CommandExtensions
{
public static void ThrowInvalidOperationException<TCommand>(
this TCommand command, string message)
where TCommand : Command
{
throw new InvalidOperationException<TCommand>(message);
}
}

class CopyCommand : Command
{
public override void Execute()
{
// after something went wrong:
this.ThrowInvalidOperationException("Something went wrong");
}
}

class CutCommand : Command
{
public override void Execute()
{
// after something went wrong:
this.ThrowInvalidOperationException("Something else went wrong");
}
}

AspNet技術(shù).NET 擴展實現(xiàn)代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 海阳市| 休宁县| 禄劝| 小金县| 石家庄市| 昭苏县| 台北县| 关岭| 习水县| 若尔盖县| 长丰县| 开鲁县| 鹿邑县| 广宗县| 恩施市| 二连浩特市| 岢岚县| 永安市| 东阳市| 璧山县| 绿春县| 道孚县| 荥经县| 安岳县| 扎囊县| 田林县| 宁乡县| 馆陶县| 古交市| 永定县| 九江县| 礼泉县| 宿松县| 峨边| 宜兴市| 太白县| 新源县| 孙吴县| 博兴县| 太和县| 麻城市|