public override void Execute() { // Routes if (this.RouteTable.Routes == null) { this.RouteTable.Routes = new List <PSRoute>(); } var vRoutes = new PSRoute(); vRoutes.AddressPrefix = this.AddressPrefix; vRoutes.NextHopType = this.NextHopType; vRoutes.NextHopIpAddress = this.NextHopIpAddress; vRoutes.Name = this.Name; this.RouteTable.Routes.Add(vRoutes); WriteObject(this.RouteTable, true); }
public override void Execute() { var vRoutesIndex = this.RouteTable.Routes.IndexOf( this.RouteTable.Routes.SingleOrDefault( resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase))); if (vRoutesIndex == -1) { throw new ArgumentException("Routes with the specified name does not exist"); } var vRoutes = new PSRoute(); vRoutes.AddressPrefix = this.AddressPrefix; vRoutes.NextHopType = this.NextHopType; vRoutes.NextHopIpAddress = this.NextHopIpAddress; vRoutes.Name = this.Name; this.RouteTable.Routes[vRoutesIndex] = vRoutes; WriteObject(this.RouteTable, true); }
public override void Execute() { base.Execute(); // 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); }
public override void Execute() { var existingRoute = this.RouteTable.Routes.SingleOrDefault(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase)); if (existingRoute != null) { throw new ArgumentException("Route with the specified name already exists"); } // Routes if (this.RouteTable.Routes == null) { this.RouteTable.Routes = new List <PSRoute>(); } var vRoutes = new PSRoute(); vRoutes.AddressPrefix = this.AddressPrefix; vRoutes.NextHopType = this.NextHopType; vRoutes.NextHopIpAddress = this.NextHopIpAddress; vRoutes.Name = this.Name; this.RouteTable.Routes.Add(vRoutes); WriteObject(this.RouteTable, true); }