Ejemplo n.º 1
0
        public ShellInitializedObservable(JoinableLazy <IVsShell> shell)
        {
            this.shell  = shell;
            initialized = new AsyncManualResetEvent();

            object zombie;

            ErrorHandler.ThrowOnFailure(shell.GetValue().GetProperty((int)__VSSPROPID.VSSPROPID_Zombie, out zombie));

            var isZombie = (bool)zombie;

            observable = Observable.Create <ShellInitialized>(async o =>
            {
                if (isZombie)
                {
                    await initialized.WaitAsync();
                }

                o.OnNext(data);
                o.OnCompleted();

                return(Disposable.Empty);
            });

            if (isZombie)
            {
                ErrorHandler.ThrowOnFailure(shell.GetValue().AdviseShellPropertyChanges(this, out cookie));
            }
        }
Ejemplo n.º 2
0
        public ShellInitializedObservable(JoinableLazy <IVsShell> shell)
        {
            this.shell = shell;
            object zombie;

            ErrorHandler.ThrowOnFailure(shell.GetValue().GetProperty((int)__VSSPROPID.VSSPROPID_Zombie, out zombie));

            var isZombie = (bool)zombie;

            if (isZombie)
            {
                ErrorHandler.ThrowOnFailure(shell.GetValue().AdviseShellPropertyChanges(this, out cookie));
            }
            else
            {
                cts.Cancel();
            }
        }
Ejemplo n.º 3
0
        int IVsShellPropertyEvents.OnShellPropertyChange(int propid, object var)
        {
            if (propid == (int)__VSSPROPID.VSSPROPID_Zombie)
            {
                if ((bool)var == false)
                {
                    ErrorHandler.ThrowOnFailure(shell.GetValue().UnadviseShellPropertyChanges(cookie));
                    cookie = 0;
                    initialized.Set();
                }
            }

            return(VSConstants.S_OK);
        }
Ejemplo n.º 4
0
        public IProjectNode Adapt(Project from)
        {
            var id = from.GetPropertyValue("ProjectGuid");

            // Fast path first.
            var          guid = Guid.Empty;
            IVsHierarchy hierarchy;

            if (!String.IsNullOrEmpty(id) && Guid.TryParse(id, out guid) &&
                ErrorHandler.Succeeded(vsSolution.GetValue().GetProjectOfGuid(ref guid, out hierarchy)))
            {
                return((IProjectNode)nodeFactory.Value.CreateNode(hierarchyItemManager.GetValue().GetHierarchyItem(hierarchy, VSConstants.VSITEMID_ROOT)));
            }

            // Slow way next
            return(asyncManager.Run(async() =>
                                    (await solutionExplorer.Value.Solution)
                                    .FindProject(x => x.PhysicalPath.Equals(from.FullPath, StringComparison.OrdinalIgnoreCase))));
        }