コード例 #1
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var route = new PSRoute();

            route.Name = this.Name;
            route.AddressPrefix = this.AddressPrefix;
            route.NextHopType = this.NextHopType;
            route.NextHopIpAddress = this.NextHopIpAddress;

            WriteObject(route);
        }
コード例 #2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            var route = new PSRoute();

            route.Name = this.Name;
            route.AddressPrefix = this.AddressPrefix;
            route.NextHopType = this.NextHopType;
            route.NextHopIpAddress = this.NextHopIpAddress;

            WriteObject(route);
        }
コード例 #3
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            // Verify if the Route exists in the RouteTable
            var route = this.RouteTable.Routes.SingleOrDefault(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));

            if (route != null)
            {
                throw new ArgumentException("Route with the specified name already exists");
            }
            
            route = new PSRoute();

            route.Name = this.Name;
            route.AddressPrefix = this.AddressPrefix;
            route.NextHopType = this.NextHopType;
            route.NextHopIpAddress = this.NextHopIpAddress;

            this.RouteTable.Routes.Add(route);

            WriteObject(this.RouteTable);
        }