Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TagTypeAttribute.cs « Tagging « TextLogic « Def « Text « src - github.com/microsoft/vs-editor-api.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 228e1bab9a208c4a0526469ad9d45687617f022e (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
//
//  Copyright (c) Microsoft Corporation. All rights reserved.
//  Licensed under the MIT License. See License.txt in the project root for license information.
//
namespace Microsoft.VisualStudio.Text.Tagging
{
    using System;
    using Microsoft.VisualStudio.Utilities;

    /// <summary>
    /// Declares the types of tags an <see cref="ITagger&lt;T&gt;"/>
    /// produces. This attribute is placed on the provider of the tagger.
    /// </summary>
    public sealed class TagTypeAttribute : MultipleBaseMetadataAttribute
    {
        private Type type;

        /// <summary>
        /// Initializes a new instance of a <see cref="TagTypeAttribute"/>.
        /// </summary>
        /// <param name="tagType">The tag type, which must derive from <see cref="ITag"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="tagType"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="tagType"/> does not derive from <see cref="ITag"/>.</exception>
        public TagTypeAttribute(Type tagType)
        {
            if (tagType == null)
                throw new ArgumentNullException("tagType");
            if (!typeof(ITag).IsAssignableFrom(tagType))
                throw new ArgumentException("Given type must derive from ITag", "tagType");

            this.type = tagType;
        }

        /// <summary>
        /// Gets the type of the tag.
        /// </summary>
        public Type TagTypes
        {
            get { return type; }
        }
    }
}