Microsoft.Azure.Commands.TrafficManager.DisableAzureTrafficManagerEndpoint.ExecuteCmdlet C# (CSharp) Method

ExecuteCmdlet() public method

public ExecuteCmdlet ( ) : void
return void
        public override void ExecuteCmdlet()
        {
            var disabled = false;
            TrafficManagerEndpoint endpointToDisable = null;

            if (this.ParameterSetName == "Fields")
            {
                endpointToDisable = new TrafficManagerEndpoint
                {
                    Name = this.Name,
                    Type = this.Type,
                    ProfileName = this.ProfileName,
                    ResourceGroupName = this.ResourceGroupName
                };
            }
            else if (this.ParameterSetName == "Object")
            {
                endpointToDisable = this.TrafficManagerEndpoint;
            }

            this.ConfirmAction(
                this.Force.IsPresent,
                string.Format(ProjectResources.Confirm_DisableEndpoint, endpointToDisable.Name, endpointToDisable.ProfileName),
                ProjectResources.Progress_DisablingEndpoint,
                this.Name,
                () =>
                {
                    disabled = this.TrafficManagerClient.EnableDisableTrafficManagerEndpoint(endpointToDisable, shouldEnableEndpointStatus: false);
                    if (disabled)
                    {
                        this.WriteVerbose(ProjectResources.Success);
                        this.WriteVerbose(string.Format(ProjectResources.Success_DisableEndpoint, endpointToDisable.Name, endpointToDisable.Name, endpointToDisable.ResourceGroupName));
                    }

                    this.WriteObject(disabled);
                });
        }
    }
DisableAzureTrafficManagerEndpoint