SolutionExtensions.InfoBarService.GetInfoBarHost C# (CSharp) Method

GetInfoBarHost() private method

private GetInfoBarHost ( string fileType ) : IVsInfoBarHost
fileType string
return IVsInfoBarHost
        private IVsInfoBarHost GetInfoBarHost(string fileType)
        {
            IVsUIShell4 uiShell = _serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell4;
            IEnumWindowFrames windowEnumerator;

            uint flags = unchecked(((uint)(__WindowFrameTypeFlags.WINDOWFRAMETYPE_Document)));
            ErrorHandler.ThrowOnFailure(uiShell.GetWindowEnum(flags, out windowEnumerator));

            IVsWindowFrame[] frame = new IVsWindowFrame[1];
            uint fetched = 0;
            int hr = VSConstants.S_OK;
            // Note that we get S_FALSE when there is no more item, so only loop while we are getting S_OK
            while (hr == VSConstants.S_OK)
            {
                // For each tool window, add it to the list
                hr = windowEnumerator.Next(1, frame, out fetched);
                ErrorHandler.ThrowOnFailure(hr);
                if (fetched == 1)
                {
                    if (frame[0].IsVisible() == VSConstants.S_OK)
                    {
                        // We successfully retrieved a window frame, update our lists
                        object obj;
                        object caption;
                        frame[0].GetProperty((int)__VSFPROPID7.VSFPROPID_InfoBarHost, out obj);
                        frame[0].GetProperty((int)__VSFPROPID.VSFPROPID_Caption, out caption);

                        if (obj != null && caption != null && caption.ToString().Contains(fileType))
                        {
                            return (IVsInfoBarHost)obj;
                        }
                    }
                }
            }

            return null;
        }
    }