protected override void ExecuteCmdlet() { if (Url == null) { ClientContext.Load(SelectedWeb, w => w.Url); ClientContext.ExecuteQueryRetry(); Url = SelectedWeb.Url; } if (Parent.HasValue) { var parentNode = SelectedWeb.Navigation.GetNodeById(Parent.Value); ClientContext.Load(parentNode); ClientContext.ExecuteQueryRetry(); var addedNode = parentNode.Children.Add(new NavigationNodeCreationInformation() { Title = Title, Url = Url, IsExternal = External.IsPresent, AsLastNode = !First.IsPresent }); ClientContext.Load(addedNode); ClientContext.ExecuteQueryRetry(); WriteObject(addedNode); } else { #pragma warning disable CS0618 // Type or member is obsolete if (!string.IsNullOrEmpty(Header)) { var newNavNode = SelectedWeb.AddNavigationNode(Title, new Uri(Url, UriKind.RelativeOrAbsolute), Header, Location, External.IsPresent, !First.IsPresent); WriteObject(newNavNode); } else { NavigationNodeCollection nodeCollection = null; if (Location == NavigationType.SearchNav) { nodeCollection = SelectedWeb.LoadSearchNavigation(); } else { nodeCollection = Location == NavigationType.QuickLaunch ? SelectedWeb.Navigation.QuickLaunch : SelectedWeb.Navigation.TopNavigationBar; ClientContext.Load(nodeCollection); } var addedNode = nodeCollection.Add(new NavigationNodeCreationInformation() { Title = Title, Url = Url, IsExternal = External.IsPresent, AsLastNode = !First.IsPresent }); ClientContext.Load(addedNode); ClientContext.ExecuteQueryRetry(); WriteObject(addedNode); } #pragma warning restore CS0618 // Type or member is obsolete } }
protected override void ExecuteCmdlet() { if (Url == null) { ClientContext.Load(SelectedWeb, w => w.Url); ClientContext.ExecuteQueryRetry(); Url = SelectedWeb.Url; } SelectedWeb.AddNavigationNode(Title, new Uri(Url, UriKind.RelativeOrAbsolute), Header, Location, External.IsPresent, !First.IsPresent); }
protected override void ExecuteCmdlet() { if (Url == null) { ClientContext.Load(SelectedWeb, w => w.Url); ClientContext.ExecuteQueryRetry(); Url = SelectedWeb.Url; } SelectedWeb.AddNavigationNode(Title, new Uri(Url), Header, Location); }