小编eva*_*n w的帖子

Visual Studio键盘生成错误的字符

我的键盘在Visual Studio中偶尔会出现错误的行为.例如,Shift + 3插入一个井号而不是一个井号#.Shift + \插入代字号〜而不是管道.当发生这种情况时,它只影响VS的当前实例 - 即使我打开了多个VS窗口.只有VS受到影响 - 记事本和其他Windows应用程序都很好.关闭然后重新打开我在新的VS 2008实例中处理的解决方案可以解决问题.

有没有人知道我不小心压制了什么组合键?以及如何还原它?

keyboard key-bindings visual-studio-2008 visual-studio

18
推荐指数
1
解决办法
5331
查看次数

使用装饰器设计模式时的问题

我们目前正在使用装饰器设计模式来执行一些缓存.所以我们有一堆看起来像这样的类:

interface IComponent
{
  object Operation();
  object AnotherOperation();
}
public ConcreteComponentA : IComponent
{
  public object Operation()
  {
    return new object();
  }
  public object AnotherOperation()
  {
    return new object();
  }
}
public ConcreteDecoratorA : IComponent
{
  protected IComponent component;
  public object Operation()
  {
    if(!this.cache.Contains("key")
    {
      this.cache["key"] = this.component.Operation();
    }
    return this.cache["key"];
}
Run Code Online (Sandbox Code Playgroud)

因此,如果客户端想要使用缓存,他们将创建一个新的ConcreteDecoratorA并将ConcreteComponentA传递给构造函数.我们面临的问题是,想象一下,AnotherOperation()需要调用Operation才能完成它的工作.ConcreteComponentA现在看起来像这样:

public ConcreteComponentA : IComponent
{
  public object Operation()
  {
    return new object();
  }
  public object AnotherOperation()
  {
    object a = this.Operation();
    // Do some other work
    return …
Run Code Online (Sandbox Code Playgroud)

c# design-patterns decorator

8
推荐指数
1
解决办法
2448
查看次数