/// <exception cref="CommunicationException">Thrown when connection failed</exception> public void Connect() { Log.Debug("Connect: begin."); if (_proxy.State != CommunicationState.Created) { Log.ErrorFormat("Connected: end. Client has invalid state {0}", _proxy.State); return; } bool coonected; try { coonected = _proxy.Connect(); } catch (Exception ex) { Log.ErrorFormat("Connect: Exception - {0}", ex.Message); throw new CommunicationException($"Connection failed to service. {ex.Message}"); } if (coonected == false) { Log.Error("Connect: end. Connection failed."); throw new CommunicationException("Connection failed"); } Log.Debug("Connect: end."); }
/// <exception cref="CommunicationException">Thrown when connection failed</exception> public void Connect() { Log.Debug("Connect: begin."); if (_proxy == null) { Log.Error("Connect: _proxy is not defined."); throw new CommunicationException("Connection failed to service. Proxy is not defined (needs to call Open)"); } if (_isConnected) { Log.Warn("Connected: end. Client is already connected."); return; } try { _isConnected = _proxy.Connect(); } catch (Exception ex) { Log.ErrorFormat("Connect: Exception - {0}", ex.Message); Close(); throw new CommunicationException($"Connection failed to service. {ex.Message}"); } if (_isConnected == false) { Log.Error("Connect: end. Connection failed."); throw new CommunicationException("Connection failed"); } Log.Debug("Connect: end."); }