Microsoft.Azure.ServiceManagemenet.Common.ProfileClient.AddOrSetEnvironment C# (CSharp) Method

AddOrSetEnvironment() public method

public AddOrSetEnvironment ( AzureEnvironment environment ) : AzureEnvironment
environment Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment
return Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment
        public AzureEnvironment AddOrSetEnvironment(AzureEnvironment environment)
        {
            if (environment == null)
            {
                throw new ArgumentNullException("environment", Resources.EnvironmentNeedsToBeSpecified);
            }

            if (AzureEnvironment.PublicEnvironments.ContainsKey(environment.Name))
            {
                throw new InvalidOperationException(
                    string.Format(Resources.ChangingDefaultEnvironmentNotSupported, "environment"));
            }

            if (Profile.Environments.ContainsKey(environment.Name))
            {
                Profile.Environments[environment.Name] =
                    MergeEnvironmentProperties(environment, Profile.Environments[environment.Name]);
            }
            else
            {
                Profile.Environments[environment.Name] = environment;
            }

            return Profile.Environments[environment.Name];
        }
        #endregion