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