/// <summary> /// Remove the given context /// </summary> /// <param name="context">The context to remove</param> /// <returns>true if the context was found and removed, otherwise false</returns> public bool TryRemoveContext(IAzureContext context) { bool result = false; string contextName; if (_profile.TryFindContext(context, out contextName)) { result = TryRemoveContext(contextName); } return(result); }
private void CompleteContextProcessing(IProfileOperations profile) { var context = profile.DefaultContext; if (context != null && context.Subscription != null && context.Subscription.State != null && !context.Subscription.State.Equals( "Enabled", StringComparison.OrdinalIgnoreCase)) { WriteWarning(string.Format( Resources.SelectedSubscriptionNotActive, context.Subscription.State)); } if (context != null) { if (MyInvocation.BoundParameters.ContainsKey(nameof(ExtendedProperty))) { foreach (var property in ExtendedProperty) { if (ShouldProcess(string.Format(Resources.ContextNameTarget, Name ?? "default"), string.Format(Resources.SetPropertyAction, property.Key, property.Value))) { context.SetProperty(property.Key, property.Value); } } } var psContext = new PSAzureContext(context); string name = Name; if (string.IsNullOrWhiteSpace(name)) { profile.TryFindContext(context, out name); } psContext.Name = name; WriteObject(psContext); } }