added some development tools
[windows-sources.git] / developer / VSSDK / VisualStudioIntegration / Common / Source / CSharp / Shell / ProvideMenuResourceAttribute.cs
blobf292c3f7e66cf31c3c6bcbdd4d29d65179aab9b6
1 //------------------------------------------------------------------------------
2 // <copyright file="ProvideMenuResourceAttribute.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 //------------------------------------------------------------------------------
7 namespace Microsoft.VisualStudio.Shell {
9 using System;
10 using System.Globalization;
12 /// <include file='doc\ProvideMenuResourceAttribute.uex' path='docs/doc[@for="ProvideMenuResourceAttribute"]' />
13 /// <devdoc>
14 /// This attribute declares that a package offers menu resources. When Visual Studio encounters
15 /// such a package it will merge the menu resource information in its menus. The attributes on a
16 /// package do not control the behavior of the package, but they can be used by registration
17 /// tools to register the proper information with Visual Studio.
18 /// </devdoc>
19 [AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
20 public sealed class ProvideMenuResourceAttribute : RegistrationAttribute {
22 private short _resourceID;
23 private int _version;
25 /// <include file='doc\ProvideMenuResourceAttribute.uex' path='docs/doc[@for="ProvideMenuResourceAttribute.ProvideMenuResourceAttribute"]' />
26 /// <devdoc>
27 /// Creates a new ProvideMenuResourceAttribute.
28 /// </devdoc>
29 public ProvideMenuResourceAttribute (short resourceID, int version) {
30 _resourceID = resourceID;
31 _version = version;
34 /// <include file='doc\ProvideMenuResourceAttribute.uex' path='docs/doc[@for="ProvideMenuResourceAttribute.ResourceID"]' />
35 /// <devdoc>
36 /// Returns the native resource ID for the menu resource.
37 /// </devdoc>
38 public short ResourceID {
39 get {
40 return _resourceID;
44 /// <include file='doc\ProvideMenuResourceAttribute.uex' path='docs/doc[@for="ProvideMenuResourceAttribute.Version"]' />
45 /// <devdoc>
46 /// Returns the version of this menu resource.
47 /// </devdoc>
48 public int Version {
49 get {
50 return _version;
54 /// <include file='doc\ProvideMenuResourceAttribute.uex' path='docs/doc[@for="Register"]' />
55 /// <devdoc>
56 /// Called to register this attribute with the given context. The context
57 /// contains the location where the registration inforomation should be placed.
58 /// it also contains such as the type being registered, and path information.
59 ///
60 /// This method is called both for registration and unregistration. The difference is
61 /// that unregistering just uses a hive that reverses the changes applied to it.
62 /// </devdoc>
63 public override void Register(RegistrationContext context) {
64 context.Log.WriteLine(SR.GetString(SR.Reg_NotifyMenuResource, ResourceID, Version));
66 using (Key childKey = context.CreateKey("Menus"))
68 childKey.SetValue(context.ComponentType.GUID.ToString("B"), string.Format(CultureInfo.InvariantCulture, ", {0}, {1}", ResourceID, Version));
72 /// <summary>
73 /// Called to unregister this attribute with the given context.
74 /// </summary>
75 /// <param name="context">
76 /// Contains the location where the registration inforomation should be placed.
77 /// It also contains other informations as the type being registered and path information.
78 /// </param>
79 public override void Unregister(RegistrationContext context) {
80 context.RemoveValue("Menus", context.ComponentType.GUID.ToString("B"));