/// <summary> /// Execute the scan /// </summary> /// <param name="config">A set of configuration options</param> /// <param name="scanTools">A set of tools for writing output files, /// creating the expected results format, and finding the target element to scan</param> /// <returns>A SnapshotCommandResult that describes the result of the command</returns> public static ScanResults Execute(Config config, IScanTools scanTools) { return(ExecutionWrapper.ExecuteCommand <ScanResults>(() => { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (scanTools == null) { throw new ArgumentNullException(nameof(scanTools)); } if (scanTools.TargetElementLocator == null) { throw new ArgumentNullException(nameof(scanTools.TargetElementLocator)); } if (scanTools.Actions == null) { throw new ArgumentNullException(nameof(scanTools.Actions)); } var rootElement = scanTools.TargetElementLocator.LocateRootElement(config.ProcessId); if (rootElement == null) { throw new InvalidOperationException(nameof(rootElement)); } return scanTools.Actions.Scan(rootElement, (element, elementId) => { return ProcessResults(element, elementId, config, scanTools); }); })); }
private IReadOnlyCollection <ScanResults> ExecuteScan(string scanId) { return(ExecutionWrapper.ExecuteCommand(() => { _scanTools.OutputFileHelper.SetScanId(scanId); return SnapshotCommand.Execute(_config, _scanTools); })); }
internal static StartCommandResult Execute(Dictionary <string, string> primaryConfig, string configFile, bool isPowerShell) { return(ExecutionWrapper.ExecuteCommand(() => { // Custom assembly resolver needs to be created before anything else, but only for PowerShell IDisposable customAssemblyResolver = isPowerShell ? new CustomAssemblyResolver() : null; CommandParameters parameters = new CommandParameters(primaryConfig, configFile); AutomationSession.NewInstance(parameters, customAssemblyResolver); return new StartCommandResult { Completed = true, SummaryMessage = DisplayStrings.SuccessStart, Succeeded = true, }; }, ErrorCommandResultFactory)); }
/// <summary> /// Execute the scan /// </summary> /// <param name="config">A set of configuration options</param> /// <param name="scanTools">A set of tools for writing output files, /// creating the expected results format, and finding the target element to scan</param> /// <returns>A SnapshotCommandResult that describes the result of the command</returns> public static ScanResults Execute(Config config, IScanTools scanTools) { return(ExecutionWrapper.ExecuteCommand <ScanResults>(() => { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (scanTools == null) { throw new ArgumentNullException(nameof(scanTools)); } if (scanTools.TargetElementLocator == null) { throw new ArgumentException(ErrorMessages.ScanToolsTargetElementLocatorNull, nameof(scanTools)); } if (scanTools.Actions == null) { throw new ArgumentException(ErrorMessages.ScanToolsActionsNull, nameof(scanTools)); } if (scanTools.NativeMethods == null) { throw new ArgumentException(ErrorMessages.ScanToolsNativeMethodsNull, nameof(scanTools)); } // We must turn on DPI awareness so we get physical, not logical, UIA element bounding rectangles scanTools.NativeMethods.SetProcessDPIAware(); var rootElement = scanTools.TargetElementLocator.LocateRootElement(config.ProcessId); if (rootElement == null) { throw new InvalidOperationException(nameof(rootElement)); } return scanTools.Actions.Scan(rootElement, (element, elementId) => { return ProcessResults(element, elementId, config, scanTools); }); })); }