public IActionResult Invoke(IRequestHandler requestHandler, string url)
        {
            IEndpointResolver endpointResolver = requestHandler.GetService <IEndpointResolver>();
            Endpoint          endpoint         = endpointResolver.GetEndpoint(requestHandler, url);

            if (endpoint == null)
            {
                return(null);
            }

            if (endpoint.DisallowAnonymous)
            {
                if (!requestHandler.HttpContext.User.Identity.IsAuthenticated || !this.HasRequiredClaims(requestHandler, endpoint))
                {
                    if (string.IsNullOrEmpty(endpoint.SignInUrl))
                    {
                        throw new HttpException(403, "Access denied.");
                    }

                    return((requestHandler as Controller).Redirect(endpoint.SignInUrl));
                }
            }

            IEndpoint endpointInstance = this.GetEndpointInstance(endpoint);

            if (endpointInstance == null)
            {
                return(null);
            }

            return(endpointInstance.Invoke(requestHandler, endpoint, endpointResolver.GetArguments(endpoint.UrlTemplate, url)));
        }
        private Endpoint CreateEndpoint(IEndpointResolver endpointResolver, ZipkinTracerOptions options)
        {
            // get defaults
            var defaultEndpoint = endpointResolver.GetEndpoint();

            // overwrite with values from user-supplied options
            return(new Endpoint
            {
                ServiceName = options.ServiceName ?? defaultEndpoint?.ServiceName ?? "Unknown",
                IPAddress = options.ServiceIpAddress ?? defaultEndpoint?.IPAddress ?? IPAddress.Loopback,
                Port = options.ServicePort != 0 ? options.ServicePort : defaultEndpoint?.Port ?? 0
            });
        }
        public Socket Connect(string hostName, int port)
        {
            var endPoint  = _endpointResolver.GetEndpoint(hostName, port);
            var ipAddress = _endpointResolver.GetIp(hostName);
            var socket    = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            var connectionStateModel = new ConnectionStateHandler
            {
                Socket = socket,
                IsConnectionSuccessful = false
            };

            Console.WriteLine($" >> Connecting [{socket.GetHashCode()}] to {endPoint}");

            socket.BeginConnect(endPoint, ConnectCallback, connectionStateModel);
            _isConnectionMade.WaitOne();

            return(connectionStateModel.IsConnectionSuccessful ? socket : null);
        }