public static RegionEndpoint GetRegionEndpoint(bool includeInstanceMetadata) { lock (_lock) { if (cachedRegion != null) { return(cachedRegion.Region); } List <Exception> errors = new List <Exception>(); IEnumerable <RegionGenerator> generators = includeInstanceMetadata ? AllGenerators : NonMetadataGenerators; foreach (var generator in generators) { try { cachedRegion = generator(); } catch (Exception e) { cachedRegion = null; errors.Add(e); } if (cachedRegion != null) { break; } } return(cachedRegion != null ? cachedRegion.Region : null); } }
public static RegionEndpoint GetRegionEndpoint(bool includeInstanceMetadata) { lock (_lock) { if (cachedRegion != null) { return(cachedRegion.Region); } List <Exception> list = new List <Exception>(); foreach (RegionGenerator item2 in (IEnumerable <RegionGenerator>)(includeInstanceMetadata ? AllGenerators : NonMetadataGenerators)) { try { cachedRegion = item2(); } catch (Exception item) { cachedRegion = null; list.Add(item); } if (cachedRegion != null) { break; } } return((cachedRegion != null) ? cachedRegion.Region : null); } }
public static void Reset() { cachedRegion = null; AllGenerators = new List <RegionGenerator> { () => new AppConfigAWSRegion() }; NonMetadataGenerators = new List <RegionGenerator> { () => new AppConfigAWSRegion() }; }
public static RegionEndpoint GetRegionEndpoint(bool includeInstanceMetadata) { lock(_lock) { if (cachedRegion != null) return cachedRegion.Region; List<Exception> errors = new List<Exception>(); IEnumerable<RegionGenerator> generators = includeInstanceMetadata ? AllGenerators : NonMetadataGenerators; foreach (var generator in generators) { try { cachedRegion = generator(); } catch (Exception e) { cachedRegion = null; errors.Add(e); } if (cachedRegion != null) break; } return cachedRegion != null ? cachedRegion.Region : null; } }