-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimileClassifierProvider.cs
More file actions
40 lines (35 loc) · 1.33 KB
/
SimileClassifierProvider.cs
File metadata and controls
40 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;
using System.ComponentModel.Composition;
namespace ConsoleCompare
{
/// <summary>
/// Classifier provider. It adds the classifier to the set of classifiers.
/// </summary>
[Export(typeof(IClassifierProvider))]
[ContentType("simile")]
internal class SimileClassifierProvider : IClassifierProvider
{
// Disable "Field is never assigned to..." compiler's warning. Justification: the field is assigned by MEF.
#pragma warning disable 649
/// <summary>
/// Classification registry to be used for getting a reference
/// to the custom classification type later.
/// </summary>
[Import]
private IClassificationTypeRegistryService classificationRegistry;
#pragma warning restore 649
#region IClassifierProvider
/// <summary>
/// Gets a classifier for the given text buffer.
/// </summary>
/// <param name="buffer">The <see cref="ITextBuffer"/> to classify.</param>
/// <returns>A classifier for the text buffer, or null if the provider cannot do so in its current state.</returns>
public IClassifier GetClassifier(ITextBuffer buffer)
{
return buffer.Properties.GetOrCreateSingletonProperty<SimileClassifier>(creator: () => new SimileClassifier(this.classificationRegistry));
}
#endregion
}
}