/// <summary> /// Public creation method /// </summary> public bool Create() { if (string.IsNullOrEmpty(HostName)) { return(false); } var rc = false; try { var binding = new BasicHttpBinding { MaxBufferSize = MAX_BUFFER, MaxReceivedMessageSize = MAX_BUFFER }; var uri = $"http://{HostName}:8000/mcneel/rockfish/5/server/basic"; var endpoint = new EndpointAddress(uri); m_factory = new ChannelFactory <IRockfishService>(binding, endpoint); m_channel = m_factory.CreateChannel(); rc = true; } catch (Exception ex) { ThrowCreationException(ex); Dispose(); } return(rc); }
/// <summary> /// Dispose /// </summary> private void Dispose(bool disposing) { if (!m_disposed) { if (disposing) { lock (m_locker) { // Close the communication channel. Note, despite the `suspicious` compiler // warning, you can do an explicit cast. The ChannelFactory.CreateChannel() // signature returns the IRockfishService interface. But is also inherits // from the IChannel interface under the hood. var channel = (IClientChannel)m_channel; try { channel.Close(); } catch { channel.Abort(); } m_channel = null; // Close the channel factory if (m_factory.State == CommunicationState.Closed) { try { m_factory.Close(); } catch { m_factory.Abort(); } m_factory = null; } } m_disposed = true; } } }