public IEndpoint CreateEndpoint(string name)
 {
     if (name == null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     _logger.LogInformation("Creating endpoint with name {EndpointName}", name);
     EndpointFactoryOptions options = _optionsMonitor.Get(name);
     if(options.EndpointFuncs.Count != 1)
     {
         throw new InvalidOperationException("There is no endpoint named that or duplicates of the same name");
     }
     return options.EndpointFuncs[0](_services);
 }
Ejemplo n.º 2
0
        public IEndpoint CreateEndpoint(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            _logger.LogInformation("Creating endpoint with name {EndpointName}", name);
            EndpointFactoryOptions options = _optionsMonitor.Get(name);

            if (options.EndpointFuncs.Count == 0)
            {
                _logger.LogDebug("Endpoint count: {0}", _optionsMonitor.CurrentValue.EndpointFuncs.Count);
                throw new InvalidOperationException($"There is no endpoint named [{name}]");
            }
            else if (options.EndpointFuncs.Count > 1)
            {
                throw new InvalidOperationException($"There duplicate endpoints with name [{name}]");
            }
            return(options.EndpointFuncs[0](_services));
        }