Partager via


ConsoleNode - Classe

Représente la structure de base utilisée pour le menu de la Console .

Hiérarchie d’héritage

System.Object
  Microsoft.SharePoint.Publishing.WebControls.ConsoleNode
    Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ModifyWebPartsNode
    Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ReportsNode

Espace de noms :  Microsoft.SharePoint.Publishing.WebControls
Assembly :  Microsoft.SharePoint.Publishing (dans Microsoft.SharePoint.Publishing.dll)

Syntaxe

'Déclaration
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Class ConsoleNode
'Utilisation
Dim instance As ConsoleNode
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class ConsoleNode

Remarques

Chaque objet ConsoleNode peut éventuellement disposer les objets enfant ConsoleNode et console ConsoleAction objets associés. Interfaces utilisateur de action tels que le menu modification , le bouton d'Accès rapide ou le menu Actions du Site présentent différentes actions à l'utilisateur. Chacune d'elles a une instance de l'objet ConsoleDataSource qui fournit une collection hiérarchique d'objets ConsoleNode . Certains objets ConsoleNode implémentent la classe ConsoleAction d'une façon spécifique.

Lorsque la propriété Action d'un ConsoleNode est définie comme un ConsoleAction, les propriétés de la ConsoleAction, tels que DisplayText et NavigateUrl, sont utilisées en tant que propriétés du même nom dans la ConsoleNode.

Lorsqu'une propriété, par exemple ImageUrl, est définie dans un objet ConsoleNode et un objet ConsoleAction qui fait référence à la ConsoleNode , la valeur spécifiée dans le ConsoleNode substitue la valeur dans la référencé ConsoleAction si la valeur de type Boolean correspondante a été définie. Dans ce cas, la définition de la propriété UseActionImageUrl à false provoque le ConsoleNode remplacer la propriété ConsoleAction .

Chaque instance de cette classe représente une action ou un sous-menu. Par exemple, dans le menu Actions du Site , si un ConsoleNode a au moins un enfant dans la collection ChildConsoleNodes , il apparaît comme la racine d'un sous-menu avec l' enfant ConsoleNodes figurant dans le sous-menu. Si le ConsoleNode n'a pas d'objets enfants, il apparaît comme une action interactive.

Exemples

using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing.WebControls;
using Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions;

namespace Microsoft.SDK.SharePointServer.Samples.Publishing.SiteActionsMenuItem
{
    /// <summary>
    /// This sample adds an item to the Site Actions menu, when clicked goes to the Navigation Settings page.
    /// 
    /// The necessary steps to make this sample running:
    /// 1. Create a new C# class library project.
    /// 2. Add this snippet to the project.
    /// 3. Sign the assembly with a strong name.
    /// 4. Add references to the following assemblies:
    ///    a. System.Web
    ///    b. Microsoft.SharePoint
    ///    c. Microsoft.SharePoint.Publishing
    /// 5. Build the project.
    /// 6. Install the assembly to the server's Global Assembly Cache (GAC).
    /// 7. Replace the assembly information given in the following XML snippet with the assembly you have created.
    ///    (trick: An easy way to learn the Public Key Token of the assembly is
    ///            to right click the assembly in GAC and click properties.)
    /// 8. Copy the XML snippet below updated with the assembly information into CustomSiteActions.xml,
    ///    which is in Editing Menu folder in Master Page Gallery.
    ///    (trick: copying can be done as follows; navigate to Site Settings, then Master Page Gallery, and then Editing Menu folder.
    ///            Download a copy of CustomSiteActions.xml, update the local copy and upload back to the server. Finally publish the file.)
    /// 9. Do an iisreset on the server.
    /// 
    /// <references>
    ///     <reference TagPrefix="SharePointServerSamples" 
    ///       assembly="Microsoft.SDK.SharePointServer.Samples.Publishing.SiteActionsMenuItem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7aa57999e9b11a7c" 
    ///       namespace="Microsoft.SDK.SharePointServer.Samples.Publishing.SiteActionsMenuItem" />
    /// </references>
    /// <structure>
    ///  <ConsoleNode
    ///       Action="SharePointServerSamples:NavigationSettingsAction"  
    ///       MenuGroupId="300"  
    ///       Sequence="390"  
    ///       PermissionContext="CurrentSite"
    ///       HideStates="IsPublishingSiteFalse"
    ///       UIVersion="4"
    ///       ID="sampleNavSetng"/>
    /// </structure>
    /// 
    /// Explanation of the ConsoleNode properties;
    /// * Action is used to define the ConsoleAction that is used with this ConsoleNode.
    /// * MenuGroupId and Sequence define the position of the ConsoleNode inside the Site Actions menu.
    /// * PermissionContext defines the context (CurrentItem, CurrentList, CurrentSite, RootSite) to be used
    ///   while checking if the user has rights to use this ConsoleNode.
    /// * HideStates defines the AuthoringStates for which the ConsoleNode is hidden (not rendered on UI.)
    /// * UIVersion can be used to define a ConsoleNode specific to a UIVersion (v3 or v4).
    /// </summary>
    public class NavigationSettingsAction : ConsoleAction
    {
        /// <summary>
        /// This is the constructor of the specific ConsoleAction.
        /// </summary>
        public NavigationSettingsAction()
            : base()
        {
            this.DisplayText = "Navigation Settings";
            this.Description = "Change the navigation settings for this site";
        }

        /// <summary>
        /// Gets the AuthoringStates required to enable the menu item.
        /// </summary>
        public override AuthoringStates RequiredStates
        {
            get
            {
                return AuthoringStates.EmptyMask;
            }
        }

        /// <summary>
        /// Gets the SPBasePermissions required to use this Console Action.
        /// </summary>
        public override SPBasePermissions UserRights
        {
            get
            {
                return SPBasePermissions.AddAndCustomizePages;
            }
        }

        /// <summary>
        /// Gets the url that the browser navigates to, when the menu item is clicked.
        /// </summary>
        public override string NavigateUrl
        {
            get
            {
                string serverRelativeUrlOfCurrentWeb = SPContext.Current.Web.ServerRelativeUrl;
                string navigationSettingsRelativeUrl = "_layouts/AreaNavigationSettings.aspx";
                string result;

                if (serverRelativeUrlOfCurrentWeb.EndsWith("/"))
                {
                    result = serverRelativeUrlOfCurrentWeb + navigationSettingsRelativeUrl;
                }
                else
                {
                    result = serverRelativeUrlOfCurrentWeb + "/" + navigationSettingsRelativeUrl;
                }

                return result;
            }
        }
    }
}

Cohérence de thread

Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.

Voir aussi

Référence

ConsoleNode - Membres

Microsoft.SharePoint.Publishing.WebControls - Espace de noms