コード例 #1
0
        public TextBlockContentInfo Create(int version, IClassificationFormatMap classificationFormatMap, TextClassifierContext context, string contentType, TextElementFlags flags, double opacity)
        {
            if (classificationFormatMap == null)
            {
                throw new ArgumentNullException(nameof(classificationFormatMap));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (contentType == null)
            {
                throw new ArgumentNullException(nameof(contentType));
            }
            var ct = contentTypeRegistryService.GetContentType(contentType);

            if (ct == null)
            {
                throw new ArgumentException($"Invalid content type: {contentType}");
            }

            if (!toAggregator.TryGetValue(ct, out var aggregator))
            {
                toAggregator.Add(ct, aggregator = textClassifierAggregatorService.Create(ct));
            }

            var tags = aggregator.GetTags(context).ToArray();

            return(new TextBlockContentInfo(textElementFactory, version, classificationFormatMap, context.Text, tags, flags, opacity));
        }
コード例 #2
0
        public FrameworkElement CreateTextElement(TreeViewNodeClassifierContext context, string contentType, bool filterOutNewLines, bool useNewFormatter)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (contentType == null)
            {
                throw new ArgumentNullException(nameof(contentType));
            }
            var ct = contentTypeRegistryService.GetContentType(contentType);

            if (ct == null)
            {
                throw new ArgumentException($"Invalid content type: {contentType}");
            }

            ITextClassifierAggregator aggregator;

            if (!toAggregator.TryGetValue(ct, out aggregator))
            {
                toAggregator.Add(ct, aggregator = textClassifierAggregatorService.Create(ct));
            }
            try {
                tagsList.AddRange(aggregator.GetTags(context));
                return(TextElementFactory.Create(classificationFormatMap, context.Text, tagsList, useNewFormatter: useNewFormatter, filterOutNewLines: filterOutNewLines));
            }
            finally {
                tagsList.Clear();
            }
        }
コード例 #3
0
        public FrameworkElement CreateTextElement(IClassificationFormatMap classificationFormatMap, TextClassifierContext context, string contentType, TextElementFlags flags)
        {
            if (classificationFormatMap == null)
            {
                throw new ArgumentNullException(nameof(classificationFormatMap));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (contentType == null)
            {
                throw new ArgumentNullException(nameof(contentType));
            }
            var ct = contentTypeRegistryService.GetContentType(contentType);

            if (ct == null)
            {
                throw new ArgumentException($"Invalid content type: {contentType}");
            }

            ITextClassifierAggregator aggregator;

            if (!toAggregator.TryGetValue(ct, out aggregator))
            {
                toAggregator.Add(ct, aggregator = textClassifierAggregatorService.Create(ct));
            }
            try {
                tagsList.AddRange(aggregator.GetTags(context));
                return(TextElementFactory.Create(classificationFormatMap, context.Text, tagsList, flags));
            }
            finally {
                tagsList.Clear();
            }
        }
コード例 #4
0
 ITextClassifier GetTextClassifier(IContentType contentType)
 {
     if (!toClassifier.TryGetValue(contentType, out var completionClassifier))
     {
         toClassifier.Add(contentType, completionClassifier = textClassifierAggregatorService.Create(contentType));
     }
     return(completionClassifier);
 }
コード例 #5
0
		public TaggedTextElementProvider(IContentType contentType, ITextClassifierAggregatorService textClassifierAggregatorService, IClassificationFormatMap classificationFormatMap) {
			if (contentType == null)
				throw new ArgumentNullException(nameof(contentType));
			if (textClassifierAggregatorService == null)
				throw new ArgumentNullException(nameof(textClassifierAggregatorService));
			if (classificationFormatMap == null)
				throw new ArgumentNullException(nameof(classificationFormatMap));
			classifierAggregator = textClassifierAggregatorService.Create(contentType);
			this.classificationFormatMap = classificationFormatMap;
		}
コード例 #6
0
 public TaggedTextElementProvider(IContentType contentType, ITextClassifierAggregatorService textClassifierAggregatorService, IClassificationFormatMap classificationFormatMap)
 {
     if (contentType is null)
     {
         throw new ArgumentNullException(nameof(contentType));
     }
     if (textClassifierAggregatorService is null)
     {
         throw new ArgumentNullException(nameof(textClassifierAggregatorService));
     }
     classifierAggregator         = textClassifierAggregatorService.Create(contentType);
     this.classificationFormatMap = classificationFormatMap ?? throw new ArgumentNullException(nameof(classificationFormatMap));
 }
コード例 #7
0
 public CompletionClassifierAggregator(ITextClassifierAggregatorService textClassifierAggregatorService, ICompletionClassifier[] completionClassifiers)
 {
     if (textClassifierAggregatorService == null)
     {
         throw new ArgumentNullException(nameof(textClassifierAggregatorService));
     }
     if (completionClassifiers == null)
     {
         throw new ArgumentNullException(nameof(completionClassifiers));
     }
     this.textClassifierAggregator = textClassifierAggregatorService.Create(new ITextClassifier[] { new TextClassifier(this) });
     this.completionClassifiers    = completionClassifiers;
 }
コード例 #8
0
 public TaggedTextElementProvider(ITextClassifierAggregatorService textClassifierAggregatorService, IClassificationFormatMap classificationFormatMap, ITextClassifier[] classifiers)
 {
     if (textClassifierAggregatorService == null)
     {
         throw new ArgumentNullException(nameof(textClassifierAggregatorService));
     }
     if (classificationFormatMap == null)
     {
         throw new ArgumentNullException(nameof(classificationFormatMap));
     }
     if (classifiers == null)
     {
         throw new ArgumentNullException(nameof(classifiers));
     }
     this.classifier = textClassifierAggregatorService.Create(classifiers);
     this.classificationFormatMap = classificationFormatMap;
 }