public static PSResourceProviderType ToPSResourceProviderType(this ProviderResourceType resourceType, string providerNamespace) { PSResourceProviderType result = new PSResourceProviderType(); if (resourceType != null) { resourceType.Locations = resourceType.Locations ?? new List <string>(); for (int i = 0; i < ResourcesClient.KnownLocationsNormalized.Count; i++) { if (resourceType.Locations.Remove(ResourcesClient.KnownLocationsNormalized[i])) { resourceType.Locations.Add(ResourcesClient.KnownLocations[i]); } } result.Name = string.IsNullOrEmpty(providerNamespace) ? resourceType.Name : string.Join("/", providerNamespace, resourceType.Name); result.Locations = resourceType.Locations.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList(); result.LocationsString = string.Join(", ", result.Locations); } return(result); }
public static PSResourceProviderType ToPSResourceProviderType(this ProviderResourceType resourceType, string providerNamespace) { PSResourceProviderType result = new PSResourceProviderType(); if (resourceType != null) { resourceType.Locations = resourceType.Locations ?? new List<string>(); for (int i = 0; i < ResourcesClient.KnownLocationsNormalized.Count; i++) { if (resourceType.Locations.Remove(ResourcesClient.KnownLocationsNormalized[i])) { resourceType.Locations.Add(ResourcesClient.KnownLocations[i]); } } result.Name = string.IsNullOrEmpty(providerNamespace) ? resourceType.Name : string.Join("/", providerNamespace, resourceType.Name); result.Locations = resourceType.Locations.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList(); result.LocationsString = string.Join(", ", result.Locations); } return result; }