Exemple #1
0
        public static Location Get(ResourceProvider provider, string name)
        {
            #region Preconditions

            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            #endregion

            switch (provider.Id)
            {
            case 2: return(Aws.Get(name));

            case 3: return(Gcp.Get(name));

            case 10: return(DigitalOcean.Get(name));

            case 105: return(GCore.Get(name));
            }

            throw ResourceError.NotFound(provider, ResourceTypes.Location, name);
        }
Exemple #2
0
        public static Location Get(int id)
        {
            var lid = LocationId.Create(id);

            if (lid.ProviderId == 2) // AWS
            {
                var region = Aws.FindByRegionNumber(lid.RegionNumber);

                return((lid.ZoneNumber != 0)
                    ? region.WithZone(ZoneHelper.GetLetter(lid.ZoneNumber))
                    : region);
            }

            if (lid.ProviderId == 3) // GCP
            {
                if (lid.Type == LocationType.MultiRegion)
                {
                    switch (lid.ZoneNumber)
                    {
                    case 1: return(Gcp.US);

                    case 2: return(Gcp.EU);

                    case 3: return(Gcp.Asia);

                    default: throw new Exception("No multi-region found:" + lid.ZoneNumber);
                    }
                }

                return(Gcp.FindByRegionNumber(lid.RegionNumber));
            }

            if (lid.ProviderId == 4) // Azure
            {
                throw new Exception("Azure is not supported");
            }

            if (lid.ProviderId == ResourceProvider.GCore.Id)
            {
                return(GCore.Get(id));
            }

            if (lid.ProviderId == 10) // Digital Ocean
            {
                return(DigitalOcean.FindByRegionNumber(lid.RegionNumber));
            }

            if (lid.ProviderId == ResourceProvider.Wasabi.Id)
            {
                return(Wasabi.FindByRegionNumber(lid.RegionNumber));
            }

            throw new Exception($"Unexpected id: {lid.ProviderId}|{lid.RegionNumber}|{lid.ZoneNumber}");
        }
Exemple #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Gcp != null ? Gcp.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Addr2 != null ? Addr2.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Addr3 != null ? Addr3.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Addr4 != null ? Addr4.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PostalCode != null ? PostalCode.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Tel != null ? Tel.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Mail != null ? Mail.GetHashCode() : 0);
         return(hashCode);
     }
 }