|
Este artículo proviene de un motor de traducción automática. Mueva el puntero sobre las frases del artículo para ver el texto original.
|
Traducción
Original
|
SPNavigationNodeCollection.Add método
Espacio de nombres: Microsoft.SharePoint.Navigation
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Parámetros
- node
- Tipo: Microsoft.SharePoint.Navigation.SPNavigationNode
El objeto de nodo (SPNavigationNode) para agregar a la colección.
- previousNode
- Tipo: Microsoft.SharePoint.Navigation.SPNavigationNode
Especifica la posición en la colección de nodos en el que se va a agregar el nuevo objeto de nodo de forma que identifica el nodo anterior a la posición donde se inserta el nuevo nodo.
Valor devuelto
Tipo: Microsoft.SharePoint.Navigation.SPNavigationNode Nota |
|---|
public override void FeatureActivated(SPFeatureReceiverProperties properties) { // Get the web site where the feature is activated. SPWeb web = properties.Feature.Parent as SPWeb; if (web == null) return; // Get the Meeting Notes document library. SPList meetingNotes = web.Lists.TryGetList("Meeting Notes"); if (meetingNotes == null) { // Create the library if it does not exist. Guid listId = web.Lists.Add("Meeting Notes", "An archive for meeting notes.", SPListTemplateType.DocumentLibrary); meetingNotes = web.Lists.GetList(listId, false); } // Check for an existing Quick Launch node for Meeting Notes. SPNavigationNode meetingNotesNode = web.Navigation.GetNodeByUrl(meetingNotes.DefaultViewUrl); // If a Meeting Notes node exists on Quick Launch, nothing more to do. if (meetingNotesNode != null) return; // Still here, so create a node for Meeting Notes. meetingNotesNode = new SPNavigationNode(meetingNotes.Title, meetingNotes.DefaultViewUrl); // Get the Libraries heading. SPNavigationNode librariesHeading = web.Navigation.GetNodeById((int)SPQuickLaunchHeading.Documents); // If the Libraries heading does not exist or it exists but has no items below it, // then Meeting Notes will be the first item. if (librariesHeading == null || librariesHeading.Children.Count == 0) { web.Navigation.AddToQuickLaunch(meetingNotesNode, SPQuickLaunchHeading.Documents); return; } // The Libraries heading exists. Now check for an item linking to Shared Documents. // If a node for Shared Documents exists, Meeting Notes will go after it. SPList sharedDocs = web.Lists.TryGetList("Shared Documents"); SPNavigationNode sharedDocsNode = null; if (sharedDocs != null) sharedDocsNode = librariesHeading .Children .Cast<SPNavigationNode>() .FirstOrDefault(n => n.Url == sharedDocs.DefaultViewUrl); // A node for Shared Documents does not exist. Make Meeting Notes the first item. if (sharedDocsNode == null) { librariesHeading.Children.AddAsFirst(meetingNotesNode); return; } // A node for Shared Documents exists. Place Meeting Notes after it. librariesHeading.Children.Add(meetingNotesNode, sharedDocsNode); web.Dispose(); }
Nota