internal bool CheckAndPrepareInput(HasControlInputCmdletBase cmdlet)
{
bool result = false;
if (null == cmdlet.InputObject) {
WriteVerbose(cmdlet, "[checking the input] Control(s) are null");
cmdlet.WriteError(
cmdlet,
"The pipeline input is null",
"InputIsNull",
ErrorCategory.InvalidArgument,
true);
}
foreach (var inputObject in cmdlet.InputObject) {
if (null == inputObject) {
WriteVerbose(cmdlet, "[checking the input] Control is null");
if (PassThru) {
WriteObject(this, inputObject);
} else {
result = false;
WriteObject(this, result);
}
result = false;
cmdlet.WriteError(
cmdlet,
"A part of the pipeline input is null",
"PartOfInputIsNull",
ErrorCategory.InvalidArgument,
false);
}
// 20131109
//System.Windows.Automation.AutomationElement _control = null;
//IUiElement _controlAdapter = null;
var _controlAdapter = inputObject;
try {
// 20131109
//_control =
// (AutomationElement)inputObject;
// 20131109
// this.WriteVerbose(
// cmdlet,
// "[checking the input] the input control is of the " +
// inputObject.Current.ControlType.ProgrammaticName +
// " type");
// 20131109
//cmdlet.currentWindow = _control;
//if (inputObject is IUiElement) {
if (null != (inputObject as IUiElement))
{
/*
if (inputObject is IUiElement) {
*/
cmdlet.CurrentInputElement = (IUiElement)_controlAdapter;
}
// if (inputObject is AutomationElement) {
// cmdlet.currentWindow = new UiElement((AutomationElement)inputObject);
// }
result = true;
// there's no need to output the True value
// since the output will be what we want
// (some part of AutomationElement, as an example)
} catch (Exception) {
if (PassThru) {
// 20131109
//WriteObject(this, _control);
WriteObject(this, _controlAdapter);
} else {
result = false;
WriteObject(this, result);
}
result = false;
return result;
}
} // 20120823
return result;
}