protected static IServiceHostBase GetHostForContext()
{
// fetch the current operation context.
OperationContext context = OperationContext.Current;
if (context == null)
{
throw new ServiceResultException(StatusCodes.BadInternalError, "The current thread does not have a valid WCF operation context.");
}
throw new ServiceResultException(StatusCodes.BadInternalError, "The endpoint is not associated with a host that supports IServerHostBase.");
}