int IVsSolutionEvents.OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            _vsHierarchyEvents = new VsHierarchyEvents(pHierarchy, _xrmToolingConnection);
            pHierarchy.AdviseHierarchyEvents(_vsHierarchyEvents, out _cookie);

            return(VSConstants.S_OK);
        }
 public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
 {
     m_myVsHierarchyEvents = new MyVsHierarchyEvents();
     pHierarchy.AdviseHierarchyEvents(m_myVsHierarchyEvents, out m_cookie);
     // do other things here ...
     return(VSConstants.S_OK);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Registers events for a given project
        /// </summary>
        /// <param name="project">The project instance on which events need to be registered</param>
        /// <param name="projectHierarchy">The hierarchy of that project instance</param>
        internal void RegisterEventsForProject(Project project, IVsHierarchy projectHierarchy)
        {
            // Check whether the project type is supported
            if (!IsSupported(project))
            {
                return;
            }

            uint cookie;
            var  hierarchyEventsHandler = new HierarchyEventsHandler(projectHierarchy);

            ErrorHandler.ThrowOnFailure(projectHierarchy.AdviseHierarchyEvents(hierarchyEventsHandler, out cookie));

            var vsproject = project.Object as VSProject;

            if (vsproject == null)
            {
                return;
            }

            var pInfo = new ProjectInfo
            {
                Cookie = cookie,
                HierarchyEventsHandler = hierarchyEventsHandler,
                ReferencesEvents       = vsproject.Events.ReferencesEvents,
            };

            pInfo.ReferencesEvents.ReferenceAdded   += ReferencesEventsHandler.ReferenceAdded;
            pInfo.ReferencesEvents.ReferenceRemoved += ReferencesEventsHandler.ReferenceRemoved;

            m_projectInfoDictionary[project.UniqueName] = pInfo;
        }
 public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
 {
     uint cookie;
     pHierarchy.AdviseHierarchyEvents(new ProjectEventSink(pHierarchy), out cookie);
     projectCookies[pHierarchy] = cookie;
     return 0;
 }
        int IVsSolutionEvents.OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            uint pc;

            pHierarchy.AdviseHierarchyEvents(new myHyEvent(pHierarchy, this), out pc);
            return(VSConstants.S_OK);
        }
Exemplo n.º 6
0
        /// <include file='doc\FlavoredProject.uex' path='docs/doc[@for="FlavoredProject.AdviseHierarchyEvents"]/*' />
        protected virtual uint AdviseHierarchyEvents(Microsoft.VisualStudio.Shell.Interop.IVsHierarchyEvents eventSink)
        {
            uint cookie = 0;

            NativeMethods.ThrowOnFailure(innerVsHierarchy.AdviseHierarchyEvents(eventSink, out cookie));
            return(cookie);
        }
 public HierarchyEventSink(IVsHierarchy hierarchy, OpenFileTracker openFileTracker)
 {
     _hierarchy       = hierarchy;
     _openFileTracker = openFileTracker;
     ErrorHandler.ThrowOnFailure(
         _hierarchy.AdviseHierarchyEvents(this, out _cookie)
         );
 }
Exemplo n.º 8
0
        public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            uint cookie;

            pHierarchy.AdviseHierarchyEvents(new ProjectEventSink(pHierarchy), out cookie);
            projectCookies[pHierarchy] = cookie;
            return(0);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object" /> class.
 /// </summary>
 /// <param name="root">Root item</param>
 /// <param name="hierarchy">The object that represents the current hierarchy</param>
 protected ItemHierarchyBase(THost root, IVsHierarchy hierarchy)
 {
     Root      = root;
     Hierarchy = hierarchy;
     Hierarchy.AdviseHierarchyEvents(this, out var cookie);
     EventCookie = cookie;
     // ReSharper disable once VirtualMemberCallInConstructor
     CollectItems();
 }
        private void AddHierarchyHandler(IVsHierarchy pHierarchy)
        {
            var handler = new HierarchyHandler(pHierarchy);

            uint handlerCode;

            pHierarchy.AdviseHierarchyEvents(handler, out handlerCode);
            handler.SetCode(handlerCode);
            _hierarchyHandlers.Add(handler);
        }
Exemplo n.º 11
0
        public ProjectHierarchy(IVsHierarchy h)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            vsHierarchy = h;
            vsHierarchy.AdviseHierarchyEvents(this, out var cookie);

            vsHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out var proj);
            Project = (proj as Project);
            Name    = Project?.Name;
        }
        public void AddHierarchy(IVsHierarchy hierarchy)
        {
            if (hierarchy == null)
            {
                return;
            }

            if (hierarchy.AdviseHierarchyEvents(this, out var cookie) == 0)
            {
                _cookies[hierarchy] = cookie;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Starts the listening.
        /// </summary>
        /// <param name="doInitialScan">if set to <c>true</c> [do initial scan].</param>
        public void StartListening(bool doInitialScan)
        {
            if (_cookie == 0)
            {
                ErrorHandler.ThrowOnFailure(_hierarchy.AdviseHierarchyEvents(this, out _cookie));

                if (doInitialScan)
                {
                    InternalScanHierarchy(VSConstants.VSITEMID_ROOT);
                }
            }
        }
Exemplo n.º 14
0
 public void StartListening(bool doInitialScan)
 {
     if (0 != cookie)
     {
         return;
     }
     Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
         hierarchy.AdviseHierarchyEvents(this, out cookie));
     if (doInitialScan)
     {
         InternalScanHierarchy(VSConstants.VSITEMID_ROOT);
     }
 }
Exemplo n.º 15
0
 public LocatorProject(IVsHierarchy hierarchy)
 {
     Hierarchy = hierarchy;
     object obj;
     int result = hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_Name, out obj);
     if (result == VSConstants.S_OK)
         Name = obj as string;
     else
         Name = string.Empty;
     Items = new List<LocatorProjectItem>();
     ProcessHierarchy(VSConstants.VSITEMID_ROOT, hierarchy);
     Hierarchy.AdviseHierarchyEvents(this, out _cookie);
 }
        public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            HierarchyEventsHandler events = new HierarchyEventsHandler(
                solution, pHierarchy);

            uint cookie;
            pHierarchy.AdviseHierarchyEvents(events, out cookie);

            string name = new HierarchyItem(pHierarchy).CanonicalName;
            hierarchyCookies[name] = cookie;

            if(fAdded != 0)
                CxxTestPackage.Instance.TryToRefreshTestSuitesView();

            return VSConstants.S_OK;
        }
Exemplo n.º 17
0
 public void StartListening()
 {
     // The listener has already been registered in the Hierachy eventHandler list
     if (0 != cookie)
     {
         return;
     }
     // Register to receive any event that append to the hierarchy
     Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
         hierarchy.AdviseHierarchyEvents(this, out cookie));
     //
     //if (doInitialScan)
     //{
     //    InternalScanHierarchy(VSConstants.VSITEMID_ROOT);
     //}
 }
        public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            HierarchyEventsHandler events = new HierarchyEventsHandler(
                solution, pHierarchy);

            uint cookie;

            pHierarchy.AdviseHierarchyEvents(events, out cookie);

            string name = new HierarchyItem(pHierarchy).CanonicalName;

            hierarchyCookies[name] = cookie;

            if (fAdded != 0)
            {
                CxxTestPackage.Instance.TryToRefreshTestSuitesView();
            }

            return(VSConstants.S_OK);
        }
Exemplo n.º 19
0
        public void StartListening()
        {
            // The listener has already been registered in the Hierachy eventHandler list
            if (0 != cookie)
            {
                return;
            }
            // Register to receive any event that append to the hierarchy
            ThreadHelper.JoinableTaskFactory.Run(async delegate
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    hierarchy.AdviseHierarchyEvents(this, out cookie));
            });
            //
            //if (doInitialScan)
            //{
            //    InternalScanHierarchy(VSConstants.VSITEMID_ROOT);
            //}
        }
Exemplo n.º 20
0
        public void SetObjects(uint count, object[] ppunk)
        {
            if (count > 0)
            {
                if (ppunk[0] is IVsBrowseObject)
                {
                    try
                    {
                        uint itemId;
                        ErrorHandler.ThrowOnFailure((ppunk[0] as IVsBrowseObject).GetProjectItem(out item, out itemId));
                        if (itemId != VSConstants.VSITEMID_ROOT)
                        {
                            throw new ArgumentException("Set Object should be given the root hierarchy");
                        }

                        string name;
                        ErrorHandler.ThrowOnFailure(item.GetCanonicalName(VSConstants.VSITEMID_ROOT, out name));
                        item.AdviseHierarchyEvents(this, out eventCookie);
                        return;
                    }
                    catch (Exception)
                    {
                        if (item != null)
                        {
                            item.UnadviseHierarchyEvents(eventCookie);
                        }
                        item = null;
                        throw;
                    }
                }
            }

            // if we could not get our hands on the project let us clear whatever we already have there
            if (item != null)
            {
                item.UnadviseHierarchyEvents(eventCookie);
            }
            item = null;
        }
Exemplo n.º 21
0
        public UIProjectInfo(UISolutionInfo solution, IVsHierarchy project, string path, string dot_ext, Icon file_icon)
        {
            // 保存基本信息
            m_solution  = solution;
            m_project   = project;
            m_path      = path;
            m_dot_ext   = dot_ext;
            m_file_icon = file_icon;

            // 加载节点信息
            LoadNodes(m_project, VSConstants.VSITEMID_ROOT, m_dot_ext);
            // 加载完成
            var server = m_solution.GetServer();

            if (server != null)
            {
                server.AddTask(() => server.LoadCompleted(m_path));
            }

            // 监听文件夹变化
            m_project.AdviseHierarchyEvents(this, out m_cookie);
        }
Exemplo n.º 22
0
 private void AdviseHierarchyEvents(IVsHierarchy pHierarchy)
 {
     try
     {
         object item;
         if (pHierarchy.GetProperty(4294967294u, -2012, out item) == 0 && item != null && item.ToString() == "Performance")
         {
             return;
         }
     }
     catch (Exception arg_2A_0)
     {
         Utils.LogExceptionQuiet(arg_2A_0);
     }
     if (!this.m_HierarchyEventMap.ContainsKey(pHierarchy))
     {
         uint cookie = 0u;
         pHierarchy.AdviseHierarchyEvents(this, out cookie);
         VSAnythingPackage.HierarchyEventInfo info = default(VSAnythingPackage.HierarchyEventInfo);
         info.m_Cookie = cookie;
         this.m_HierarchyEventMap[pHierarchy] = info;
     }
 }
 int IVsSolutionEvents.OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
 {
     _vsHierarchyEvents = new VsHierarchyEvents(pHierarchy, _reportList);
     pHierarchy.AdviseHierarchyEvents(_vsHierarchyEvents, out _cookie);
     return VSConstants.S_OK;
 }
Exemplo n.º 24
0
 int IVsSolutionEvents.OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
 {
     _vsHierarchyEvents = new VsHierarchyEvents(pHierarchy, _webResouceList);
     pHierarchy.AdviseHierarchyEvents(_vsHierarchyEvents, out _cookie);
     return(VSConstants.S_OK);
 }
 public HierarchyListener(IVsHierarchy hierarchy, OAProjectConfigurationProperties props)
 {
     _hierarchy = hierarchy;
     _props     = props;
     ErrorHandler.ThrowOnFailure(_hierarchy.AdviseHierarchyEvents(this, out _cookie));
 }
 public int AdviseHierarchyEvents(IVsHierarchyEvents pEventSink, out uint pdwCookie)
 {
     return(_hierarchy.AdviseHierarchyEvents(pEventSink, out pdwCookie));
 }
 public bool TryAdviseHierarchy()
 {
     return(ErrorHandler.Succeeded(_hierarchy.AdviseHierarchyEvents(this, out _cookie)));
 }