コード例 #1
0
        protected IIntellisensePresenter FindPresenter
            (IIntellisenseSession session,
            IList <Lazy <IIntellisensePresenterProvider, IOrderableContentTypeMetadata> > orderedPresenterProviders,
            IGuardedOperations guardedOperations)
        {
            var buffers = Helpers.GetBuffersForTriggerPoint(session);

            foreach (var presenterProviderExport in orderedPresenterProviders)
            {
                foreach (var buffer in buffers)
                {
                    foreach (var contentType in presenterProviderExport.Metadata.ContentTypes)
                    {
                        if (buffer.ContentType.IsOfType(contentType))
                        {
                            IIntellisensePresenter presenter = guardedOperations.InstantiateExtension(
                                session, presenterProviderExport,
                                factory => factory.TryCreateIntellisensePresenter(session));
                            if (presenter != null)
                            {
                                return(presenter);
                            }
                        }
                    }
                }
            }

            return(null);
        }
コード例 #2
0
ファイル: Helpers.cs プロジェクト: noah1510/dotdevelop
        internal static IEnumerable <TStyle> GetMatchingPresenterStyles <TSession, TStyle>
            (TSession session,
            IList <Lazy <TStyle, IOrderableContentTypeMetadata> > orderedPresenterStyles,
            IGuardedOperations guardedOperations)
            where TSession : IIntellisenseSession
        {
            List <TStyle> styles = new List <TStyle>();

            ITextView     textView           = session.TextView;
            SnapshotPoint?surfaceBufferPoint = session.GetTriggerPoint(textView.TextSnapshot);

            if (surfaceBufferPoint == null)
            {
                return(styles);
            }

            var buffers = Helpers.GetBuffersForTriggerPoint(session).ToList();

            foreach (var styleExport in orderedPresenterStyles)
            {
                bool usedThisProviderAlready = false;
                foreach (var buffer in buffers)
                {
                    foreach (string contentType in styleExport.Metadata.ContentTypes)
                    {
                        if (buffer.ContentType.IsOfType(contentType))
                        {
                            var style = guardedOperations.InstantiateExtension(styleExport, styleExport);
                            if (!Object.Equals(style, default(TStyle)))
                            {
                                styles.Add(style);
                            }
                            usedThisProviderAlready = true;
                            break;
                        }
                    }
                    if (usedThisProviderAlready)
                    {
                        break;
                    }
                }
            }

            return(styles);
        }