protected SoapMessage <WSD.ProbeMatchesType> ProbeDevice( bool multicast, DiscoveryUtils.DiscoveryType[][] types, string[] scopes, string matchRule, Discovery.ProcessMessage processMessageMethod) { System.Diagnostics.Trace.WriteLine(string.Format("ProbeDevice: entry point")); System.Diagnostics.Trace.Flush(); SoapMessage <WSD.ProbeMatchesType> response = null; Discovery discovery = new Discovery(_nic.IP, processMessageMethod); discovery.Discovered += OnDiscovered; discovery.DiscoveryFinished += OnDiscoveryFinished; discovery.SoapFaultReceived += OnSoapFault; discovery.ReceiveError += OnDiscoveryError; discovery.MessageSent += OnMessageSent; _eventProbeMatchReceived = new AutoResetEvent(false); _eventTimeout = new AutoResetEvent(false); _eventFaultReceived = new AutoResetEvent(false); _eventDiscoveryError = new AutoResetEvent(false); int res = -1; try { discovery.Probe(multicast, _cameraIp, null, _messageTimeout, types, scopes, matchRule); res = WaitForResponse(new WaitHandle[] { _eventProbeMatchReceived, _eventTimeout, _eventFaultReceived, _eventDiscoveryError }); if (res == 0) { response = _message.ToSoapMessage <WSD.ProbeMatchesType>(); } else if (res == 2) { throw new SoapFaultException(_soapFault); } else if (res == 3) { string message = _error.Message + _error.InnerException ?? " " + _error.InnerException.Message; throw new AssertException(message); } } finally { System.Diagnostics.Trace.WriteLine(string.Format("ProbeDevice: discovery.Dispose, res = {0}", res)); System.Diagnostics.Trace.Flush(); discovery.Dispose(); } return(response); }
protected SoapMessage <WSD.ProbeMatchesType> ProbeDeviceStep( bool multicast, DiscoveryUtils.DiscoveryType[][] types, string[] scopes, string matchRule, Discovery.ProcessMessage processMessageMethod) { SoapMessage <WSD.ProbeMatchesType> response = null; RunStep(() => { response = ProbeDevice(multicast, types, scopes, matchRule, processMessageMethod); if (response == null) { throw new AssertException(Resources.ErrorNoProbeResponse_Text); } else { string dump = System.Text.Encoding.UTF8.GetString(response.Raw); LogResponse(dump); } }, Resources.StepProbeDevice_Title); return(response); }