public override void Execute()
        {
            base.Execute();

            // Verify if the delegation exists in the Subnet
            PSDelegation delegation = null;

            if (this.Subnet.Delegations != null)
            {
                delegation = this.Subnet.Delegations.SingleOrDefault(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));
            }
            else
            {
                this.Subnet.Delegations = new List <PSDelegation>();
            }

            if (delegation != null)
            {
                throw new ArgumentException($"Delegation with the specified name '{this.Name}' already exists.");
            }

            delegation = new PSDelegation();

            delegation.Name        = this.Name;
            delegation.ServiceName = this.ServiceName;

            this.Subnet.Delegations.Add(delegation);
            WriteObject(this.Subnet);
        }
예제 #2
0
        public override void Execute()
        {
            base.Execute();

            var delegation = new PSDelegation
            {
                Name        = this.Name,
                ServiceName = this.ServiceName
            };

            WriteObject(delegation);
        }