public IP2CountryResolver(IEnumerable <IIP2CountryDataSource> ipDataSources, IPAddressComparer ipAddressComparer) { if (ipDataSources.Any(i => i == null)) { throw new ArgumentNullException(nameof(ipDataSources)); } _comparer = ipAddressComparer ?? throw new ArgumentNullException(nameof(ipAddressComparer)); _ipinfo = ipDataSources .SelectMany(d => d.Read()) .GroupBy(i => i.Start.AddressFamily) .ToDictionary(g => g.Key, g => g.OrderBy(i => i.Start, _comparer).ToArray()); }
public IP2CountryResolver(IIP2CountryDataSource ipDataSource, IPAddressComparer ipAddressComparer) : this(new[] { ipDataSource }, ipAddressComparer) { }