blob: cd105aa76fde79f20b71b7fb1e46aa1d5dd45056 (
plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
using System;
namespace Microsoft.VisualStudio.Text.Tagging
{
/// <summary>
/// Associates an <see cref="ITag" /> with a given <see cref="SnapshotSpan" />.
/// </summary>
/// <typeparam name="T">The type, which must be a subclass of <see cref="ITag"/>.</typeparam>
/// <remarks>
/// Use <see cref="TagSpan<T>" /> as the implementation of this
/// interface.
/// </remarks>
public interface ITagSpan<out T> where T : ITag
{
/// <summary>
/// Gets the tag located in this span.
/// </summary>
T Tag { get; }
/// <summary>
/// Gets the snapshot span for this tag.
/// </summary>
SnapshotSpan Span { get; }
}
/// <summary>
/// The implementation of ITagSpan<T>.
/// </summary>
public class TagSpan<T> : ITagSpan<T> where T : ITag
{
#region ITagSpan<T> members
/// <summary>
/// Gets the tag located in this span.
/// </summary>
public T Tag { get; private set; }
/// <summary>
/// Gets the snapshot span for this tag.
/// </summary>
public SnapshotSpan Span { get; private set; }
#endregion
/// <summary>
/// Initializes a new instance of a <see cref="TagSpan<T>"/> with the specified snapshot span and tag.
/// </summary>
/// <param name="span">The <see cref="SnapshotSpan"/> with which to associate the tag.</param>
/// <param name="tag">The tag associated with the span.</param>
/// <exception cref="ArgumentNullException"><paramref name="tag"/> is null.</exception>
public TagSpan(SnapshotSpan span, T tag)
{
if (tag == null)
throw new ArgumentNullException("tag");
Span = span;
Tag = tag;
}
}
}
|