本文整理汇总了C#中System.Windows.Automation.CacheRequest.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# CacheRequest.Pop方法的具体用法?C# CacheRequest.Pop怎么用?C# CacheRequest.Pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Automation.CacheRequest
的用法示例。
在下文中一共展示了CacheRequest.Pop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubscribeToEvents
//.........这里部分代码省略.........
// 20130327
//this.WriteObject(cmdlet, uiaEventHandler);
if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
break;
case "AutomationElementIdentifiers.MenuOpenedEvent":
this.WriteVerbose(cmdlet, "subscribing to the MenuOpenedEvent handler");
Automation.AddAutomationEventHandler(
AutomationElement.MenuOpenedEvent,
inputObject,
TreeScope.Subtree,
uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
// 20130327
//this.WriteObject(cmdlet, uiaEventHandler);
if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
break;
case "AutomationElementIdentifiers.ToolTipClosedEvent":
this.WriteVerbose(cmdlet, "subscribing to the ToolTipClosedEvent handler");
Automation.AddAutomationEventHandler(
AutomationElement.ToolTipClosedEvent,
inputObject,
TreeScope.Subtree,
uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
// 20130327
//this.WriteObject(cmdlet, uiaEventHandler);
if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
break;
case "AutomationElementIdentifiers.ToolTipOpenedEvent":
this.WriteVerbose(cmdlet, "subscribing to the ToolTipOpenedEvent handler");
Automation.AddAutomationEventHandler(
AutomationElement.ToolTipOpenedEvent,
inputObject,
TreeScope.Subtree,
uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
// 20130327
//this.WriteObject(cmdlet, uiaEventHandler);
if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
break;
case "AutomationElementIdentifiers.AutomationFocusChangedEvent":
WriteVerbose(cmdlet, "subscribing to the AutomationFocusChangedEvent handler");
Automation.AddAutomationFocusChangedEventHandler(
//AutomationElement.AutomationFocusChangedEvent,
//inputObject,
//System.Windows.Automation.AutomationElement.RootElement,
//TreeScope.Subtree,
uiaFocusChangedEventHandler = new AutomationFocusChangedEventHandler(cmdlet.AutomationEventHandler));
UIAHelper.WriteEventToCollection(cmdlet, uiaFocusChangedEventHandler);
// 20130327
//this.WriteObject(cmdlet, uiaFocusChangedEventHandler);
if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaFocusChangedEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
break;
default:
this.WriteVerbose(cmdlet,
"the following event has not been subscribed to: " +
eventType.ProgrammaticName);
break;
}
this.WriteVerbose(cmdlet, "on the object " + inputObject.Current.Name);
cacheRequest.Pop();
}
catch (Exception e) {
// try {
// ErrorRecord err = new ErrorRecord(
// e,
// "RegisteringEvent",
// ErrorCategory.OperationStopped,
// inputObject);
// err.ErrorDetails =
// new ErrorDetails("Unable to register event handler " +
// // handler.ToString());
// eventType.ProgrammaticName +
// " for " +
// inputObject.Current.Name);
// // this.OnSuccessAction.ToString());
// WriteError(this, err, false);
// }
// catch {
// ErrorRecord err = new ErrorRecord(
// e,
// "RegisteringEvent",
// ErrorCategory.OperationStopped,
// inputObject);
// err.ErrorDetails =
// new ErrorDetails("Unable to register event handler " +
// eventType.ProgrammaticName);;
// WriteError(this, err, false);
// }
WriteVerbose(cmdlet,
"Unable to register event handler " +
eventType.ProgrammaticName +
" for " +
inputObject.Current.Name);
WriteVerbose(cmdlet,
e.Message);
}
}