コード例 #1
0
#pragma warning restore CS0649
        #endregion

        /// <summary>
        /// Factory function for a CBETagger instance.
        /// Used by VS to create the tagger
        /// </summary>
        public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag
        {
            // provide the tag only on the top-level buffer
            if (textView.TextBuffer != buffer)
            {
                return(null);
            }

            // Check if content type (language) is supported and active for tagging
            var type = textView.TextBuffer.ContentType;

            if (!CBETagPackage.IsLanguageSupported(type.TypeName))
            {
                return(null);
            }

            // only works with IWpfTextView
            if (textView is IWpfTextView wpfTextView)
            {
                // return new instance of CBETagger
                return(new CBETagger(this, wpfTextView) as ITagger <T>);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        IEnumerable <ITagSpan <IntraTextAdornmentTag> > ITagger <IntraTextAdornmentTag> .GetTags(NormalizedSnapshotSpanCollection spans)
        {
            // Check if content type (language) is supported and active for tagging
            if (CBETagPackage.IsLanguageSupported(_TextView.TextBuffer.ContentType.TypeName))
            {
                // Second chance to hook up events
                InitializePackage();

                foreach (var span in spans)
                {
                    var tags = GetTags(span);
                    foreach (var tag in tags)
                    {
                        yield return(tag);
                    }
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CBETagPackage"/> class.
 /// </summary>
 public CBETagPackage()
 {
     _instance = this;
 }