public void TermEndpoint([NotNull] string addr)
{
CheckContextTerminated();
// Check whether endpoint address passed to the function is valid.
if (addr == null)
throw new ArgumentNullException("addr");
// Process pending commands, if any, since there could be pending unprocessed process_own()'s
// (from launch_child() for example) we're asked to terminate now.
ProcessCommands(0, false);
string protocol;
string address;
DecodeAddress(addr, out address, out protocol);
CheckProtocol(protocol);
if (protocol == Address.InProcProtocol)
{
if (UnregisterEndpoint(addr, this))
return;
Pipe pipe;
if (!m_inprocs.TryGetValue(addr, out pipe))
throw new EndpointNotFoundException("Endpoint was not found and cannot be disconnected");
pipe.Terminate(true);
m_inprocs.Remove(addr);
}
else
{
Endpoint endpoint;
if (!m_endpoints.TryGetValue(addr, out endpoint))
throw new EndpointNotFoundException("Endpoint was not found and cannot be disconnected");
if (endpoint.Pipe != null)
endpoint.Pipe.Terminate(false);
TermChild(endpoint.Own);
m_endpoints.Remove(addr);
}
}