ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.GetIpAddress C# (CSharp) Method

GetIpAddress() public static method

public static GetIpAddress ( System context ) : IPAddress
context System
return System.Net.IPAddress
        public static IPAddress GetIpAddress(System.ServiceModel.OperationContext context)
        {
            #if !MONO
            var prop = context.IncomingMessageProperties;
            if (context.IncomingMessageProperties.ContainsKey(System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name))
            {
                var endpoint = prop[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name]
                    as System.ServiceModel.Channels.RemoteEndpointMessageProperty;
                if (endpoint != null)
                {
                    return IPAddress.Parse(endpoint.Address);
                }
            }
            #endif
            return null;
        }