/// <inheritdoc /> public async Task <bool> HasEntryAsync(ClientRegionLocale locale, NetworkServiceType serviceType) { if (!Enum.IsDefined(typeof(ClientRegionLocale), locale)) { throw new ArgumentOutOfRangeException(nameof(locale), "Value should be defined in the ClientRegionLocale enum."); } if (!Enum.IsDefined(typeof(NetworkServiceType), serviceType)) { throw new ArgumentOutOfRangeException(nameof(serviceType), "Value should be defined in the NetworkServiceType enum."); } return(await EndpointsContext.Endpoints.AnyAsync(e => e.Region == locale && e.Service == serviceType)); }
} //must have setter for EF public NamedResolvedEndpointEntryModel(ClientRegionLocale region, NetworkServiceType service, string endpointAddress, int endpointPort) { if (!Enum.IsDefined(typeof(ClientRegionLocale), region)) { throw new ArgumentOutOfRangeException(nameof(region), "Value should be defined in the ClientRegionLocale enum."); } if (!Enum.IsDefined(typeof(NetworkServiceType), service)) { throw new ArgumentOutOfRangeException(nameof(service), "Value should be defined in the NetworkServiceType enum."); } if (string.IsNullOrWhiteSpace(endpointAddress)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(endpointAddress)); } Region = region; Service = service; EndpointAddress = endpointAddress; EndpointPort = endpointPort; }
/// <inheritdoc /> public async Task <ResolvedEndpoint> RetrieveAsync(ClientRegionLocale locale, NetworkServiceType serviceType) { if (!Enum.IsDefined(typeof(ClientRegionLocale), locale)) { throw new ArgumentOutOfRangeException(nameof(locale), "Value should be defined in the ClientRegionLocale enum."); } if (!Enum.IsDefined(typeof(NetworkServiceType), serviceType)) { throw new ArgumentOutOfRangeException(nameof(serviceType), "Value should be defined in the NetworkServiceType enum."); } NamedResolvedEndpointEntryModel model = await EndpointsContext.Endpoints.FirstOrDefaultAsync(e => e.Region == locale && e.Service == serviceType); if (model == null) { throw new KeyNotFoundException($"Provided keypair {locale} and {serviceType} not found."); } return(new ResolvedEndpoint(model.EndpointAddress, model.EndpointPort)); }