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.
7 //------------------------------------------------------------------------------
10 using System
.Globalization
;
12 namespace Microsoft
.VisualStudio
.Shell
15 /// This attribute adds a logical view to the editor created by an editor factory.
17 [Obsolete("RegisterEditorLogicalViewAttribute has been deprecated. Please use ProvideEditorLogicalViewAttribute instead.")]
18 [AttributeUsage(AttributeTargets
.Class
, AllowMultiple
=true, Inherited
=true)]
19 public sealed class RegisterEditorLogicalViewAttribute
: RegistrationAttribute
22 private Guid logicalView
;
25 /// Creates a new RegisterEditorLogicalView attribute to register a logical
26 /// view provided by your editor.
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
;
42 throw new ArgumentException(string.Format(Resources
.Culture
, Resources
.Attributes_InvalidFactoryType
, factoryType
));
47 /// Get the Guid representing the type of the editor factory
49 public Guid FactoryType
55 /// Get the Guid representing the logical view
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
")); }
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.
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
"), "");
84 /// Unregister this logical view.
86 /// <param name="context
"></param>
87 public override void Unregister(RegistrationContext context)
89 context.RemoveValue(LogicalViewPath, logicalView.ToString("B
"));