示例#1
0
        public IList <Endpoint> AnalyzeAddress(string address)
        {
            if (Uri.TryCreate(address, UriKind.Absolute, out Uri result))
            {
                var definitions = _endpointDefinitionFactory.GetEndpointDefinitions(address);
                if (definitions == null)
                {
                    throw new Exception($"Could not parse service at address {address}");
                }

                // TODO avoid running _endpointFactory.LoadEndpointFromDefinition multiple times for the same address (unless address actually makes a difference?)
                var endpoints = definitions.Select(x => _endpointFactory.LoadEndpointFromDefinition(x)).ToList();
                if (endpoints.Any(x => x == null))
                {
                    throw new Exception($"Could not parse service at address {address}");
                }

                foreach (var endpoint in endpoints)
                {
                    _endpointCache.Add(endpoint);
                }

                return(endpoints);
            }
            else
            {
                var error = $"{address} is not a valid URL for a WCF Service";
                throw new Exception(error);
            }
        }
示例#2
0
        public string LoadEndpointsFromSettings()
        {
            try
            {
                _endpointCache.Clear();

                var definitions = _endpointCache.LoadDefinitionsFromSettings();
                _endpointCache.DeleteEndpointFolders(definitions.Select(x => x.EndpointDirectory).ToList());

                var endpoints = new List <Endpoint>();
                foreach (var definition in definitions)
                {
                    var endpoint = _endpointFactory.LoadEndpointFromDefinition(definition);
                    _endpointCache.Add(endpoint);
                    endpoints.Add(endpoint);
                }

                return(Json(endpoints));
            }
            catch (Exception e)
            {
                return(Json(new Error(e)));
            }
        }