CommandID.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / ComponentModel / Design / CommandID.cs / 1305376 / CommandID.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

/* 
 */ 
namespace System.ComponentModel.Design {
    using System; 
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Globalization;
    using System.Security.Permissions; 

    ///  
    ///     
    ///       Represents a
    ///       numeric Command ID and globally unique 
    ///       ID (GUID) menu identifier that together uniquely identify a command.
    ///    
    /// 
    [HostProtection(SharedState = true)] 
    [System.Runtime.InteropServices.ComVisible(true)]
    [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")] 
    [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")] 
    public class CommandID {
        private readonly Guid menuGroup; 
        private readonly int  commandID;

        /// 
        ///     
        ///       Initializes a new instance of the 
        ///       class. Creates a new command 
        ///       ID. 
        ///    
        ///  
        public CommandID(Guid menuGroup, int commandID) {
            this.menuGroup = menuGroup;
            this.commandID = commandID;
        } 

        ///  
        ///     
        ///       Gets or sets the numeric command ID.
        ///     
        /// 
        public virtual int ID {
            get {
                return commandID; 
            }
        } 
 
        /// 
        ///     
        ///       Overrides Object's Equals method.
        ///    
        /// 
        public override bool Equals(object obj) { 
            if (!(obj is CommandID)) {
                return false; 
            } 
            CommandID cid = (CommandID)obj;
            return cid.menuGroup.Equals(menuGroup) && cid.commandID == commandID; 
        }

        /// 
        ///    [To be supplied.] 
        /// 
        public override int GetHashCode() { 
            return menuGroup.GetHashCode() << 2 | commandID; 
        }
 
        /// 
        ///    
        ///       Gets or sets the globally
        ///       unique ID 
        ///       (GUID) of the menu group that the menu command this CommandID
        ///       represents belongs to. 
        ///     
        /// 
        public virtual Guid Guid { 
            get {
                return menuGroup;
            }
        } 

        ///  
        ///     
        ///       Overrides Object's ToString method.
        ///     
        /// 
        public override string ToString() {
            return menuGroup.ToString() + " : " + commandID.ToString(CultureInfo.CurrentCulture);
        } 
    }
 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

/* 
 */ 
namespace System.ComponentModel.Design {
    using System; 
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Globalization;
    using System.Security.Permissions; 

    ///  
    ///     
    ///       Represents a
    ///       numeric Command ID and globally unique 
    ///       ID (GUID) menu identifier that together uniquely identify a command.
    ///    
    /// 
    [HostProtection(SharedState = true)] 
    [System.Runtime.InteropServices.ComVisible(true)]
    [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")] 
    [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")] 
    public class CommandID {
        private readonly Guid menuGroup; 
        private readonly int  commandID;

        /// 
        ///     
        ///       Initializes a new instance of the 
        ///       class. Creates a new command 
        ///       ID. 
        ///    
        ///  
        public CommandID(Guid menuGroup, int commandID) {
            this.menuGroup = menuGroup;
            this.commandID = commandID;
        } 

        ///  
        ///     
        ///       Gets or sets the numeric command ID.
        ///     
        /// 
        public virtual int ID {
            get {
                return commandID; 
            }
        } 
 
        /// 
        ///     
        ///       Overrides Object's Equals method.
        ///    
        /// 
        public override bool Equals(object obj) { 
            if (!(obj is CommandID)) {
                return false; 
            } 
            CommandID cid = (CommandID)obj;
            return cid.menuGroup.Equals(menuGroup) && cid.commandID == commandID; 
        }

        /// 
        ///    [To be supplied.] 
        /// 
        public override int GetHashCode() { 
            return menuGroup.GetHashCode() << 2 | commandID; 
        }
 
        /// 
        ///    
        ///       Gets or sets the globally
        ///       unique ID 
        ///       (GUID) of the menu group that the menu command this CommandID
        ///       represents belongs to. 
        ///     
        /// 
        public virtual Guid Guid { 
            get {
                return menuGroup;
            }
        } 

        ///  
        ///     
        ///       Overrides Object's ToString method.
        ///     
        /// 
        public override string ToString() {
            return menuGroup.ToString() + " : " + commandID.ToString(CultureInfo.CurrentCulture);
        } 
    }
 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK