/// <summary> /// For conversion from serialized PSObjects /// </summary> /// <param name="other"></param> public PSAzureEnvironment(PSObject other) { if (other == null || other.Properties == null) { throw new ArgumentNullException(nameof(other)); } Name = other.GetProperty <string>(nameof(Name)); EnableAdfsAuthentication = other.GetProperty <bool>(nameof(EnableAdfsAuthentication)); OnPremise = other.GetProperty <bool>(nameof(OnPremise)); ActiveDirectoryAuthority = other.GetProperty <string>(nameof(ActiveDirectoryAuthority)); ActiveDirectoryServiceEndpointResourceId = other.GetProperty <string>(nameof(ActiveDirectoryServiceEndpointResourceId)); AdTenant = other.GetProperty <string>(nameof(AdTenant)); AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = other.GetProperty <string>(nameof(AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix)); AzureDataLakeStoreFileSystemEndpointSuffix = other.GetProperty <string>(nameof(AzureDataLakeStoreFileSystemEndpointSuffix)); DataLakeEndpointResourceId = other.GetProperty <string>(nameof(DataLakeEndpointResourceId)); AzureKeyVaultDnsSuffix = other.GetProperty <string>(nameof(AzureKeyVaultDnsSuffix)); AzureKeyVaultServiceEndpointResourceId = other.GetProperty <string>(nameof(AzureKeyVaultServiceEndpointResourceId)); BatchEndpointResourceId = other.GetProperty <string>(nameof(BatchEndpointResourceId)); GalleryUrl = other.GetProperty <string>(nameof(GalleryUrl)); GraphEndpointResourceId = other.GetProperty <string>(nameof(GraphEndpointResourceId)); GraphUrl = other.GetProperty <string>(nameof(GraphUrl)); ManagementPortalUrl = other.GetProperty <string>(nameof(ManagementPortalUrl)); PublishSettingsFileUrl = other.GetProperty <string>(nameof(PublishSettingsFileUrl)); ResourceManagerUrl = other.GetProperty <string>(nameof(ResourceManagerUrl)); ServiceManagementUrl = other.GetProperty <string>(nameof(ServiceManagementUrl)); SqlDatabaseDnsSuffix = other.GetProperty <string>(nameof(SqlDatabaseDnsSuffix)); StorageEndpointSuffix = other.GetProperty <string>(nameof(StorageEndpointSuffix)); TrafficManagerDnsSuffix = other.GetProperty <string>(nameof(TrafficManagerDnsSuffix)); VersionProfiles.Populate(nameof(VersionProfiles), other); this.PopulateExtensions(other); }
public bool Equals(AzureEnvironment other) { if (other == null) { return(false); } var unequalItemsDict = other.ExtendedProperties.Where(keyValuePair => !ExtendedProperties[keyValuePair.Key] .Equals(keyValuePair.Value, StringComparison.OrdinalIgnoreCase)) .ToDictionary(entry => entry.Key, entry => entry.Value); if (unequalItemsDict.Any()) { return(false); } var thisNotOther = VersionProfiles.Except(other.VersionProfiles, StringComparer.OrdinalIgnoreCase).ToList(); var otherNotThis = other.VersionProfiles.Except(VersionProfiles, StringComparer.OrdinalIgnoreCase).ToList(); if (thisNotOther.Any() || otherNotThis.Any()) { return(false); } return(string.Equals(this.Name, other.Name, StringComparison.OrdinalIgnoreCase) && this.OnPremise == other.OnPremise && string.Equals(this.ServiceManagementUrl?.TrimEnd('/'), other.ServiceManagementUrl?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.ResourceManagerUrl?.TrimEnd('/'), other.ResourceManagerUrl?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.ManagementPortalUrl?.TrimEnd('/'), other.ManagementPortalUrl?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.PublishSettingsFileUrl?.TrimEnd('/'), other.PublishSettingsFileUrl?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.ActiveDirectoryAuthority?.TrimEnd('/'), other.ActiveDirectoryAuthority?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.GalleryUrl?.TrimEnd('/'), other.GalleryUrl?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.GraphUrl?.TrimEnd('/'), other.GraphUrl?.TrimEnd('/')?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.ActiveDirectoryServiceEndpointResourceId?.TrimEnd('/'), other.ActiveDirectoryServiceEndpointResourceId?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.StorageEndpointSuffix, other.StorageEndpointSuffix, StringComparison.OrdinalIgnoreCase) && string.Equals(this.SqlDatabaseDnsSuffix, other.SqlDatabaseDnsSuffix, StringComparison.OrdinalIgnoreCase) && string.Equals(this.TrafficManagerDnsSuffix, other.TrafficManagerDnsSuffix, StringComparison.OrdinalIgnoreCase) && string.Equals(this.AzureKeyVaultDnsSuffix, other.AzureKeyVaultDnsSuffix, StringComparison.OrdinalIgnoreCase) && string.Equals(this.AzureKeyVaultServiceEndpointResourceId?.TrimEnd('/'), other.AzureKeyVaultServiceEndpointResourceId?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.GraphEndpointResourceId?.TrimEnd('/'), other.GraphEndpointResourceId?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.DataLakeEndpointResourceId?.TrimEnd('/'), other.DataLakeEndpointResourceId?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.BatchEndpointResourceId?.TrimEnd('/'), other.BatchEndpointResourceId?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix, other.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix, StringComparison.OrdinalIgnoreCase) && string.Equals(this.AzureDataLakeStoreFileSystemEndpointSuffix, other.AzureDataLakeStoreFileSystemEndpointSuffix, StringComparison.OrdinalIgnoreCase) && string.Equals(this.AdTenant?.TrimEnd('/'), other.AdTenant?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase) && string.Equals(this.ContainerRegistryEndpointSuffix?.TrimEnd('/'), other.ContainerRegistryEndpointSuffix?.TrimEnd('/'), StringComparison.OrdinalIgnoreCase)); }