Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: obsolete/Microsoft.VisualStudio.Project/SelectionListener.cs

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /// Copyright (c) Microsoft Corporation. All rights reserved.
2
3 using System;
4 using System.Diagnostics;
5 using Microsoft.VisualStudio;
6 using Microsoft.VisualStudio.Shell;
7 using Microsoft.VisualStudio.Shell.Interop;
8 using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants;
9
10 namespace Microsoft.VisualStudio.Project
11 {
12
13 [CLSCompliant(false)]
14 public abstract class SelectionListener : IVsSelectionEvents, IDisposabl e
15 {
16 #region fields
17 private uint eventsCookie;
18 private IVsMonitorSelection monSel;
19 private ServiceProvider serviceProvider;
20 private bool isDisposed;
21 /// <summary>
22 /// Defines an object that will be a mutex for this object for s ynchronizing thread calls.
23 /// </summary>
24 private static volatile object Mutex = new object();
25 #endregion
26
27 #region ctors
28 protected SelectionListener(ServiceProvider serviceProvider)
29 {
30
31 this.serviceProvider = serviceProvider;
32 this.monSel = serviceProvider.GetService(typeof(SVsShell MonitorSelection)) as IVsMonitorSelection;
33
34 if(this.monSel == null)
35 {
36 throw new InvalidOperationException();
37 }
38 }
39 #endregion
40
41 #region properties
42 protected uint EventsCookie
43 {
44 get
45 {
46 return this.eventsCookie;
47 }
48 }
49
50 protected IVsMonitorSelection SelectionMonitor
51 {
52 get
53 {
54 return this.monSel;
55 }
56 }
57
58 protected ServiceProvider ServiceProvider
59 {
60 get
61 {
62 return this.serviceProvider;
63 }
64 }
65 #endregion
66
67 #region IVsSelectionEvents Members
68
69 public virtual int OnCmdUIContextChanged(uint dwCmdUICookie, int fActive)
70 {
71 return VSConstants.E_NOTIMPL;
72 }
73
74 public virtual int OnElementValueChanged(uint elementid, object varValueOld, object varValueNew)
75 {
76 return VSConstants.E_NOTIMPL;
77 }
78
79 public virtual int OnSelectionChanged(IVsHierarchy pHierOld, uin t itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarch y pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCN ew)
80 {
81 return VSConstants.E_NOTIMPL;
82 }
83
84 #endregion
85
86 #region IDisposable Members
87 /// <summary>
88 /// The IDispose interface Dispose method for disposing the obje ct determinastically.
89 /// </summary>
90 public void Dispose()
91 {
92 this.Dispose(true);
93 GC.SuppressFinalize(this);
94 }
95 #endregion
96
97 #region methods
98 public void Init()
99 {
100 if(this.SelectionMonitor != null)
101 {
102 ErrorHandler.ThrowOnFailure(this.SelectionMonito r.AdviseSelectionEvents(this, out this.eventsCookie));
103 }
104 }
105
106 /// <summary>
107 /// The method that does the cleanup.
108 /// </summary>
109 /// <param name="disposing"></param>
110 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usag e", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.VisualStudio.Shell .Interop.IVsMonitorSelection.UnadviseSelectionEvents(System.UInt32)")]
111 protected virtual void Dispose(bool disposing)
112 {
113 // Everybody can go here.
114 if(!this.isDisposed)
115 {
116 // Synchronize calls to the Dispose simultenious ly.
117 lock(Mutex)
118 {
119 if(disposing && this.eventsCookie != (ui nt)ShellConstants.VSCOOKIE_NIL && this.SelectionMonitor != null)
120 {
121 this.SelectionMonitor.UnadviseSe lectionEvents((uint)this.eventsCookie);
122 this.eventsCookie = (uint)ShellC onstants.VSCOOKIE_NIL;
123 }
124
125 this.isDisposed = true;
126 }
127 }
128 }
129 #endregion
130
131 }
132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698