added some development tools
[windows-sources.git] / developer / VSSDK / VisualStudioIntegration / Common / Source / CSharp / Shell100 / RegisterEditorLogicalViewAttribute.cs
blob003da942cc9cc1e9fe1daf61f11eb7f5041987ac
1 //------------------------------------------------------------------------------
2 // <copyright from='2003' to='2004' company='Microsoft Corporation'>
3 // Copyright (c) Microsoft Corporation, All rights reserved.
4 // This code sample is provided "AS IS" without warranty of any kind,
5 // it is not recommended for use in a production environment.
6 // </copyright>
7 //------------------------------------------------------------------------------
9 using System;
10 using System.Globalization;
12 namespace Microsoft.VisualStudio.Shell
14 /// <summary>
15 /// This attribute adds a logical view to the editor created by an editor factory.
16 /// </summary>
17 [Obsolete("RegisterEditorLogicalViewAttribute has been deprecated. Please use ProvideEditorLogicalViewAttribute instead.")]
18 [AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
19 public sealed class RegisterEditorLogicalViewAttribute : RegistrationAttribute
21 private Guid factory;
22 private Guid logicalView;
24 /// <summary>
25 /// Creates a new RegisterEditorLogicalView attribute to register a logical
26 /// view provided by your editor.
27 /// </summary>
28 /// <param name="factoryType">The type of factory; can be a Type, a GUID or a string representation of a GUID</param>
29 /// <param name="logicalViewGuid">The guid of the logical view to register.</param>
30 public RegisterEditorLogicalViewAttribute(object factoryType, string logicalViewGuid)
32 this.logicalView = new Guid(logicalViewGuid);
34 // figure out what type of object they passed in and get the GUID from it
35 if (factoryType is string)
36 this.factory = new Guid((string)factoryType);
37 else if (factoryType is Type)
38 this.factory = ((Type)factoryType).GUID;
39 else if (factoryType is Guid)
40 this.factory = (Guid)factoryType;
41 else
42 throw new ArgumentException(string.Format(Resources.Culture, Resources.Attributes_InvalidFactoryType, factoryType));
46 /// <summary>
47 /// Get the Guid representing the type of the editor factory
48 /// </summary>
49 public Guid FactoryType
51 get {return factory;}
54 /// <summary>
55 /// Get the Guid representing the logical view
56 /// </summary>
57 public Guid LogicalView
59 get {return logicalView;}
62 private string LogicalViewPath
64 get { return string.Format(CultureInfo.InvariantCulture, "Editors\\{0}\\LogicalViews", factory.ToString("B")); }
68 /// <summary>
69 /// Called to register this attribute with the given context. The context
70 /// contains the location where the registration inforomation should be placed.
71 /// It also contains other information such as the type being registered and path information.
72 /// </summary>
73 public override void Register(RegistrationContext context)
75 context.Log.WriteLine(string.Format(Resources.Culture, Resources.Reg_NotifyEditorView, logicalView.ToString("B")));
77 using (Key childKey = context.CreateKey( LogicalViewPath ))
79 childKey.SetValue(logicalView.ToString("B"), "");
83 /// <summary>
84 /// Unregister this logical view.
85 /// </summary>
86 /// <param name="context"></param>
87 public override void Unregister(RegistrationContext context)
89 context.RemoveValue(LogicalViewPath, logicalView.ToString("B"));