<meta http-equiv="X-UA-Compatible" content="chrome=1">
X-UA-Compatible 是仅支持IE8的。过不了多久你就会发现,网上有百分之XX的网页上加了这句话。
嗯。如果,Google Frame再绑定一个什么迅雷,QQ之类的。哇咔,以后打开IE8,会发现突然变快了,还不知怎么回事呢,原来是Chrome的功劳呀。不错,好棋。
<meta http-equiv="X-UA-Compatible" content="chrome=1">
尝试在C#3.0中用扩展方法模拟突变赋值功能:
上面对object类定义了MAssign扩展方法,通过反射获取和设置属性值模拟突变赋值。这样,我们就可以对任意对象进行突变赋值了:
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");
}
}