Base class for determining region based on inspection.
Exemple #1
0
        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);
            }
        }
Exemple #2
0
 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);
     }
 }
Exemple #3
0
 public static void Reset()
 {
     cachedRegion  = null;
     AllGenerators = new List <RegionGenerator>
     {
         () => new AppConfigAWSRegion()
     };
     NonMetadataGenerators = new List <RegionGenerator>
     {
         () => new AppConfigAWSRegion()
     };
 }
Exemple #4
0
        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;
            }
        }