.NET 擴(kuò)展實(shí)現(xiàn)代碼
{
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");
}
}
相關(guān)文章
asp.net 結(jié)合mysql存儲(chǔ)過(guò)程進(jìn)行分頁(yè)代碼
最近用mysql + asp.net來(lái)寫(xiě)網(wǎng)站,既然mysql已經(jīng)支持存儲(chǔ)過(guò)程了,那么像分頁(yè)這么常用的東西,當(dāng)然要用存儲(chǔ)過(guò)程啦2008-11-11MVC微信網(wǎng)頁(yè)授權(quán)獲取用戶(hù)OpenId
這篇文章主要為大家詳細(xì)介紹了MVC微信網(wǎng)頁(yè)授權(quán),在模板頁(yè)中獲取用戶(hù)openid,感興趣的小伙伴們可以參考一下2016-09-09.net數(shù)據(jù)庫(kù)操作框架SqlSugar的簡(jiǎn)單入門(mén)
這篇文章主要介紹了.net數(shù)據(jù)庫(kù)操作框架SqlSugar的簡(jiǎn)單入門(mén),幫助大家更好的理解和學(xué)習(xí)使用.net技術(shù),感興趣的朋友可以了解下2021-04-04asp.net下判斷用戶(hù)什么時(shí)候離開(kāi),以什么方式離開(kāi)
asp.net下判斷用戶(hù)什么時(shí)候離開(kāi),以什么方式離開(kāi)...2007-03-03.NET Core中HttpClient的正確打開(kāi)方式
這篇文章主要給大家介紹了關(guān)于.NET Core中HttpClient的正確打開(kāi)方式,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-01-01ASP.NET MVC3 SEO優(yōu)化:利用Routing特性提高站點(diǎn)權(quán)重
這篇文章主要介紹了ASP.NET MVC3 SEO優(yōu)化:利用Routing特性消除多個(gè)路徑指向同一個(gè)Action,從而提高站點(diǎn)權(quán)重,需要的朋友可以參考下。2016-06-06.NET讀寫(xiě)Excel工具Spire.Xls使用入門(mén)教程(1)
這篇文章主要為大家詳細(xì)介紹了.NET讀寫(xiě)Excel工具Spire.Xls使用入門(mén)教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-11-11