private static bool IsRegionInPartition(string regionName, JsonData partition, out string description)
{
JsonData regionsData = partition["regions"];
string regionPattern = (string)partition["regionRegex"];
// see if the region name is a real region
if (regionsData[regionName] != null)
{
description = (string) regionsData[regionName]["description"];
return true;
}
// see if the region is global region by concatenating the partition and "-global" to construct the global name
// for the partition
else if (regionName.Equals(string.Concat((string)partition["partition"], "-global"), StringComparison.OrdinalIgnoreCase))
{
description = "Global";
return true;
}
// no region key in the entry, but it matches the pattern in this partition.
// we can try to construct an endpoint based on the heuristics described in endpoints.json
else if (new Regex(regionPattern).Match(regionName).Success)
{
description = GetUnknownRegionDescription(regionName);
return true;
}
else
{
description = GetUnknownRegionDescription(regionName);
return false;
}
}