コード例 #1
0
 public void Dispose()
 {
     if (this.ContextManager != null)
     {
         this.ContextManager.ContextChanged -= new EventHandler <ContextChangedEventArgs>(this.ContextManager_ContextChanged);
     }
     this.ContextManager = null;
 }
コード例 #2
0
        public virtual void Initialize(object sender, SectionInitializeEventArgs e)
        {
            m_provider = e.ServiceProvider;
            ITeamFoundationContextManager tfContextManager = GetService <ITeamFoundationContextManager>();

            m_vcServer = tfContextManager.CurrentContext.TeamProjectCollection.GetService <VersionControlServer>();
            m_vcServer.CommitCheckin += vcServer_CommitCheckin;
        }
コード例 #3
0
 public void Dispose()
 {
     if (this.ContextManager != null)
     {
         this.ContextManager.ContextChanged -= new EventHandler<ContextChangedEventArgs>(this.ContextManager_ContextChanged);
     }
     this.ContextManager = null;
 }
コード例 #4
0
 /// <summary>
 /// Initializes the section, obtaining service dependencies as available,
 /// and subscribing to changes in the current team project collection.
 /// </summary>
 public virtual void Initialize(object sender, SectionInitializeEventArgs e)
 {
     if (!m_isInitialized)
     {
         m_provider       = e.ServiceProvider;
         m_contextManager = GetService <ITeamFoundationContextManager>();
         m_contextManager.ContextChanged += ContextManager_ContextChanged;
         SetVersionControlServer(m_contextManager.CurrentContext);
         m_isInitialized = true;
     }
 }
コード例 #5
0
ファイル: GitFlowPage.cs プロジェクト: jmezach/GitFlow.VS
        public GitFlowPage([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
        {
            Title = "GitFlow";
            teamFoundationContextManager = (ITeamFoundationContextManager)serviceProvider.GetService(typeof(ITeamFoundationContextManager4));
            gitService = (IGitExt)serviceProvider.GetService(typeof(IGitExt));
            gitService.PropertyChanged += OnGitServicePropertyChanged;

            var outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            var customGuid = new Guid("B85225F6-B15E-4A8A-AF6E-2BE96A4FE672");
            outWindow.CreatePane(ref customGuid, "GitFlow.VS", 1, 1);
            outWindow.GetPane(ref customGuid, out outputWindow);
        }
コード例 #6
0
 private void Dispose(bool isDisposing)
 {
     if (isDisposing)
     {
         if (m_contextManager != null)
         {
             m_contextManager.ContextChanged -= ContextManager_ContextChanged;
         }
         RemoveVersionControlReferences();
         m_contextManager = null;
         m_provider       = null;
     }
 }
コード例 #7
0
        protected void UnsubscribeContextChanges()
        {
            if (this.ServiceProvider == null || !this.contextSubscribed)
            {
                return;
            }

            ITeamFoundationContextManager tfcontextManager = this.GetService <ITeamFoundationContextManager>();

            if (tfcontextManager != null)
            {
                tfcontextManager.ContextChanged -= this.ContextChanged;
            }
        }
コード例 #8
0
        /// <summary>
        /// Unsubscribe from context changes.
        /// </summary>
        protected void UnsubscribeContextChanges()
        {
            if (serviceProvider == null || !contextIsSubscribed)
            {
                return;
            }

            ITeamFoundationContextManager tfContextManager = GetService <ITeamFoundationContextManager>();

            if (tfContextManager != null)
            {
                tfContextManager.ContextChanged -= ContextChanged;
            }
        }
コード例 #9
0
        public void Execute()
        {
            if (this.ServiceProvider != null)
            {
                ITeamExplorer service = this.ServiceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
                if (this.ContextManager == null)
                {
                    this.ContextManager = (ITeamFoundationContextManager)this.ServiceProvider.GetService(typeof(ITeamFoundationContextManager));
                }
                if (this.ContextManager != null)
                {
                    this.ContextManager.ContextChanged += new EventHandler <ContextChangedEventArgs>(this.ContextManager_ContextChanged);
                }
                if (service != null)
                {
                    if (NavigationItemCandidates != null)
                    {
                        string text = string.Empty;

                        foreach (var navigationItemCandidates in NavigationItemCandidates)
                        {
                            if (!navigationItemCandidates.IsValueCreated)
                            {
                                continue;
                            }

                            text += navigationItemCandidates.Value.Text + Environment.NewLine;
                        }

                        service.ShowNotification(text, NotificationType.Information, NotificationFlags.None, null, Guid.NewGuid());
                    }
                    else
                    {
                        service.ShowNotification("This is a simple notification", NotificationType.Information, NotificationFlags.None, null, new Guid());
                    }

                    //ITeamExplorer explorer = ServiceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
                    //if (explorer != null)
                    //{
                    //    var page = explorer.CurrentPage;
                    //    string info = page.GetId().ToString() + Environment.NewLine;
                    //    var sections = page.GetSections();
                    //    foreach (var section in sections)
                    //        info += section.Title + " " + section.GetId() + Environment.NewLine;
                    //    MessageBox.Show(info);
                    //}
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Subscribe to context changes.
        /// </summary>
        protected void SubscribeContextChanges()
        {
            Debug.Assert(ServiceProvider != null, "ServiceProvider must be set before subscribing to context changes");
            if (ServiceProvider == null || m_contextSubscribed)
            {
                return;
            }

            ITeamFoundationContextManager tfContextManager = GetService <ITeamFoundationContextManager>();

            if (tfContextManager != null)
            {
                tfContextManager.ContextChanged += ContextChanged;
                m_contextSubscribed              = true;
            }
        }
コード例 #11
0
        /// <summary>Initializes a new instance of the TeamExplorerIntegrator class, The constructor for the Add-in object. Place your initialization code within this method.</summary> 
        public TeamExplorerIntegrator(EnvDTE.IVsExtensibility extensibility, ITeamFoundationContextManager te)
        {
            this.dirtyPath = new List<string>();
            this.tfsContextManager = te;

            // get IDE Globals object and DTE from that
            EnvDTE80.DTE2 dte2 = extensibility.GetGlobalsObject(null).DTE as EnvDTE80.DTE2;
            this.applicationObject = dte2;

            Debug.Assert(dte2 != null, "No DTE2");

            TeamFoundationServerExt tfsExt = (TeamFoundationServerExt)dte2.Application.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt");
            this.srcCtrlExplorer = (VersionControlExt)dte2.Application.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt");

            this.DoConnect(tfsExt);
        }
コード例 #12
0
        public void Invalidate()
        {
            if (_contextManager == null && ServiceProvider != null)
            {
                _contextManager = ServiceProvider.GetService(typeof(ITeamFoundationContextManager)) as ITeamFoundationContextManager;
                if (_contextManager != null)
                {
                    _contextManager.ContextChanged += _contextManager_ContextChanged;
                    UpdateText(_contextManager.CurrentContext);
                }
            }

            if (_service == null && ServiceProvider != null)
            {
                _service = ServiceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
            }
        }
コード例 #13
0
        public void Execute()
        {
            if (this.ServiceProvider != null)
            {
                ITeamExplorer service = this.ServiceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
                if (this.ContextManager == null)
                {
                    this.ContextManager = (ITeamFoundationContextManager)this.ServiceProvider.GetService(typeof(ITeamFoundationContextManager));
                }
                if (this.ContextManager != null)
                {
                    this.ContextManager.ContextChanged += new EventHandler<ContextChangedEventArgs>(this.ContextManager_ContextChanged);
                }
                if (service != null)
                {
                    if (NavigationItemCandidates != null)
                    {
                        string text = string.Empty;

                        foreach (var navigationItemCandidates in NavigationItemCandidates)
                        {
                            if (!navigationItemCandidates.IsValueCreated)
                                continue;

                            text += navigationItemCandidates.Value.Text + Environment.NewLine;
                        }

                        service.ShowNotification(text, NotificationType.Information, NotificationFlags.None, null, Guid.NewGuid());
                    }
                    else
                        service.ShowNotification("This is a simple notification", NotificationType.Information, NotificationFlags.None, null, new Guid());

                    //ITeamExplorer explorer = ServiceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
                    //if (explorer != null)
                    //{
                    //    var page = explorer.CurrentPage;
                    //    string info = page.GetId().ToString() + Environment.NewLine;
                    //    var sections = page.GetSections();
                    //    foreach (var section in sections)
                    //        info += section.Title + " " + section.GetId() + Environment.NewLine;
                    //    MessageBox.Show(info);
                    //}
                }
            }
        }
コード例 #14
0
        public TeamFoundationHostWrapper(ITeamFoundationContextManager teamFoundationHostObject)
        {
            _teamFoundationHostObject = teamFoundationHostObject;
            _teamFoundationHostObject.ContextChanged += delegate(object sender, ContextChangedEventArgs args)
            {
                if (ContextChanged != null)
                {
                    ContextChanged(sender, args);
                }
            };

            _teamFoundationHostObject.ContextChanging += delegate(object sender, ContextChangingEventArgs args)
            {
                if (ContextChanging != null)
                {
                    ContextChanging(sender, args);
                }
            };

            _teamFoundationHostObjectType     = _teamFoundationHostObject.GetType();
            _commandHandlerField              = new Lazy <FieldInfo>(() => _teamFoundationHostObjectType.GetField("m_commandHandler", BindingFlags.NonPublic | BindingFlags.Instance));
            _promptForServerAndProjectsMethod = new Lazy <MethodInfo>(() => _teamFoundationHostObjectType.GetMethod("PromptForServerAndProjects", BindingFlags.Public | BindingFlags.Instance));

            var connectingEventInfo = _teamFoundationHostObjectType.GetEvent("Connecting", BindingFlags.Public | BindingFlags.Instance);
            var connectingEventHandlerConstructor = connectingEventInfo.EventHandlerType.GetConstructor(new[] { typeof(object), typeof(IntPtr) });
            var connectingEventHandler            = (Delegate)connectingEventHandlerConstructor.Invoke(new object[]
            {
                this, typeof(TeamFoundationHostWrapper).GetMethod("TeamFoundationHostConnecting", BindingFlags.NonPublic | BindingFlags.Instance).MethodHandle.GetFunctionPointer()
            });

            connectingEventInfo.AddEventHandler(_teamFoundationHostObject, connectingEventHandler);

            var connectionCompletedEventInfo = _teamFoundationHostObjectType.GetEvent("ConnectionCompleted", BindingFlags.Public | BindingFlags.Instance);
            var connectionCompletedEventHandlerConstructor = connectionCompletedEventInfo.EventHandlerType.GetConstructor(new[] { typeof(object), typeof(IntPtr) });
            var connectionCompletedEventHandler            = (Delegate)connectionCompletedEventHandlerConstructor.Invoke(new object[]
            {
                this, typeof(TeamFoundationHostWrapper).GetMethod("TeamFoundationHostConnectionCompleted", BindingFlags.NonPublic | BindingFlags.Instance).MethodHandle.GetFunctionPointer()
            });

            connectionCompletedEventInfo.AddEventHandler(_teamFoundationHostObject, connectionCompletedEventHandler);
        }
コード例 #15
0
        public TeamFoundationHostWrapper(ITeamFoundationContextManager teamFoundationHostObject)
        {
            _teamFoundationHostObject = teamFoundationHostObject;
            _teamFoundationHostObject.ContextChanged += delegate(object sender, ContextChangedEventArgs args)
                {
                    if (ContextChanged != null)
                        ContextChanged(sender, args);
                };

            _teamFoundationHostObject.ContextChanging += delegate(object sender, ContextChangingEventArgs args)
                {
                    if (ContextChanging != null)
                        ContextChanging(sender, args);
                };

            _teamFoundationHostObjectType = _teamFoundationHostObject.GetType();
            _commandHandlerField = new Lazy<FieldInfo>(() => _teamFoundationHostObjectType.GetField("m_commandHandler", BindingFlags.NonPublic | BindingFlags.Instance));
            _promptForServerAndProjectsMethod = new Lazy<MethodInfo>(() => _teamFoundationHostObjectType.GetMethod("PromptForServerAndProjects", BindingFlags.Public | BindingFlags.Instance));

            var connectingEventInfo = _teamFoundationHostObjectType.GetEvent("Connecting", BindingFlags.Public | BindingFlags.Instance);
            var connectingEventHandlerConstructor = connectingEventInfo.EventHandlerType.GetConstructor(new[] { typeof(object), typeof(IntPtr) });
            var connectingEventHandler = (Delegate)connectingEventHandlerConstructor.Invoke(new object[]
                {
                    this, typeof (TeamFoundationHostWrapper).GetMethod("TeamFoundationHostConnecting", BindingFlags.NonPublic | BindingFlags.Instance).MethodHandle.GetFunctionPointer()
                });

            connectingEventInfo.AddEventHandler(_teamFoundationHostObject, connectingEventHandler);

            var connectionCompletedEventInfo = _teamFoundationHostObjectType.GetEvent("ConnectionCompleted", BindingFlags.Public | BindingFlags.Instance);
            var connectionCompletedEventHandlerConstructor = connectionCompletedEventInfo.EventHandlerType.GetConstructor(new[] { typeof(object), typeof(IntPtr) });
            var connectionCompletedEventHandler = (Delegate)connectionCompletedEventHandlerConstructor.Invoke(new object[]
                {
                    this, typeof (TeamFoundationHostWrapper).GetMethod("TeamFoundationHostConnectionCompleted", BindingFlags.NonPublic | BindingFlags.Instance).MethodHandle.GetFunctionPointer()
                });

            connectionCompletedEventInfo.AddEventHandler(_teamFoundationHostObject, connectionCompletedEventHandler);
        }