当我输入时git diff,我想用我选择的视觉差异工具(Windows上的SourceGear"diffmerge")查看输出.如何配置git来执行此操作?
我正在使用一个在C#中转发事件的类.我想知道是否有一种方法可以减少代码开销.
这是我到目前为止所拥有的一个例子.
class A
{
public event EventType EventA;
}
class B
{
A m_A = new A();
public event EventType EventB;
public B()
{
m_A.EventA += OnEventA;
}
public void OnEventA()
{
if( EventB )
{
EventB();
}
}
}
Run Code Online (Sandbox Code Playgroud)
A级引发原始事件.B类将其转发为EventB(基本上是同一事件).A类对其他模块是隐藏的,因此无法直接订阅EventA.
我正在尝试做的是减少B类中用于转发事件的代码开销,因为通常没有真正处理类B中的事件.此外,我将有几个不同的事件,因此需要编写大量的OnEvent ()B类中仅用于转发事件的方法.
是否有可能以某种方式自动将EventA链接到EventB,所以我会有这样的事情:
class B
{
A m_A = new A();
public event EventType EventB;
public B()
{
m_A.EventA += EventB; // EventA automatically raises EventB.
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用C#2.0编译器btw.
我有以下界面,我正在尝试使COM可见.当我尝试生成类型库时,它不喜欢我的实现类派生自泛型类的事实.
是否可以将泛型类用作COM实现类?(我知道我可以编写一个非通用的包装器并将其导出到COM,但是这会添加另一个我宁愿不用的层.)
[ComVisible(true)]
public interface IMyClass
{
...
}
[ComVisible(true), ComDefaultInterface(typeof(IMyClass))]
[ClassInterface(ClassInterfaceType.None)]
public class MyClass : BaseClass<IMyClass>, IMyClass
{
...
}
Run Code Online (Sandbox Code Playgroud)
错误信息:
Warning: Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute.