public static TModelNode AddDeleteTopNavigationNodes <TModelNode>(this TModelNode model,
                                                                   DeleteTopNavigationNodesDefinition definition,
                                                                   Action <DeleteTopNavigationNodesModelNode> action)
     where TModelNode : ModelNode, IWebHostModelNode, new()
 {
     return(model.AddTypedDefinitionNode(definition, action));
 }
Exemple #2
0
        private void DeployDefinition(object modelHost, WebModelHost typedModelHost, DeleteTopNavigationNodesDefinition typedDefinition)
        {
            var web     = typedModelHost.HostWeb;
            var context = web.Context;

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioning,
                Object           = web,
                ObjectType       = typeof(Web),
                ObjectDefinition = typedDefinition,
                ModelHost        = modelHost
            });

            if (typedDefinition.NavigationNodes != null && typedDefinition.NavigationNodes.Any())
            {
                var nodesCollection = GetNavigationNodeCollection(web);

                context.Load(nodesCollection);
                context.ExecuteQueryWithTrace();

                DeleteNavigationNodesService.DeleteNodesByMatch(typedDefinition, nodesCollection, url =>
                {
                    return(ResolveTokenizedUrl(typedModelHost, url));
                });
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioned,
                Object           = web,
                ObjectType       = typeof(Web),
                ObjectDefinition = typedDefinition,
                ModelHost        = modelHost
            });
        }
 public static TModelNode AddDeleteTopNavigationNodes <TModelNode>(this TModelNode model,
                                                                   DeleteTopNavigationNodesDefinition definition)
     where TModelNode : ModelNode, IWebHostModelNode, new()
 {
     return(AddDeleteTopNavigationNodes(model, definition, null));
 }