如何为 Outlook Inspectors 正确实现 Wrapper class
How to implement a Wrapper class for the Outlook Inspectors correctly
C#、VSTO、Outlook 2016
我找到了 Connect class。但是当我尝试连接 NewInspector 事件时,总是会出现 IDE1007 错误。
public class Connect
{
private Outlook.Inspectors inspectors;
private List<OutlookInspector> inspectorWindows;
inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(inspectors_NewInspector);
void inspectors_NewInspector(Outlook.Inspector Inspector) {
// Check to see if this is a new window you don't already track
OutlookInspector existingWindow = FindOutlookInspector(Inspector);
if ( existingWindow == null ) {
AddInspector(Inspector);
}
}
显然没有找到检查员。我在这里错过了什么?
稍后在 OutlookInspector.FindOutlookInspector 方法中找不到 Window 变量:
private OutlookInspector FindOutlookInspector(object window) {
foreach ( OutlookInspector inspector in inspectorWindows ) {
if ( inspector.Window == window ) {
return inspector;
}
}
return null;
}
嗯,当然 - inspectors.NewInspector +=
行在任何方法之外。我怀疑它一定在构造函数中:
public Connect(Outlook.Inspectors Inspectors)
{
inspectors = Inspectors;
inspectorWindows = new List<OutlookInspector>();
inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(inspectors_NewInspector);
}
然后您需要构建 Connect
class 的实例并将 Application.Inspectors
传递给它。
C#、VSTO、Outlook 2016
我找到了 Connect class。但是当我尝试连接 NewInspector 事件时,总是会出现 IDE1007 错误。
public class Connect
{
private Outlook.Inspectors inspectors;
private List<OutlookInspector> inspectorWindows;
inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(inspectors_NewInspector);
void inspectors_NewInspector(Outlook.Inspector Inspector) {
// Check to see if this is a new window you don't already track
OutlookInspector existingWindow = FindOutlookInspector(Inspector);
if ( existingWindow == null ) {
AddInspector(Inspector);
}
}
显然没有找到检查员。我在这里错过了什么?
稍后在 OutlookInspector.FindOutlookInspector 方法中找不到 Window 变量:
private OutlookInspector FindOutlookInspector(object window) {
foreach ( OutlookInspector inspector in inspectorWindows ) {
if ( inspector.Window == window ) {
return inspector;
}
}
return null;
}
嗯,当然 - inspectors.NewInspector +=
行在任何方法之外。我怀疑它一定在构造函数中:
public Connect(Outlook.Inspectors Inspectors)
{
inspectors = Inspectors;
inspectorWindows = new List<OutlookInspector>();
inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(inspectors_NewInspector);
}
然后您需要构建 Connect
class 的实例并将 Application.Inspectors
传递给它。