Exemplo n.º 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));
        }
        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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 4
0
 ITextClassifier GetTextClassifier(IContentType contentType)
 {
     if (!toClassifier.TryGetValue(contentType, out var completionClassifier))
     {
         toClassifier.Add(contentType, completionClassifier = textClassifierAggregatorService.Create(contentType));
     }
     return(completionClassifier);
 }
		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;
		}
Exemplo n.º 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));
 }
 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;
 }
Exemplo n.º 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;
 }