欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

.NET 擴(kuò)展實(shí)現(xiàn)代碼

 更新時(shí)間:2008年09月14日 08:30:40   作者:  
增強(qiáng).net的功能需要用到了擴(kuò)展實(shí)現(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");
}
}

相關(guān)文章

最新評(píng)論