CollectionTagger<T> Class
Provides a thread-safe ITagger<T> implementation that maintains a simple collection of tagged ranges.
public abstract class CollectionTagger<T> : TaggerBase<T>, ICollectionTagger<T>, ITagger<T>, ITaggerBase, IOrderable, IKeyedObject where T : class, ITag
- Type Parameters:
-
T-The type of tag associated with this tagger.
- Inheritance:
- object TaggerBase<T> object
- Derived:
- DelimiterHighlightTagger IndicatorTaggerBase<TTag> ParseErrorTagger SearchResultHighlightTagger
- Implements:
- ICollectionTagger<T> ITagger<T> ITaggerBase IOrderable IKeyedObject
Constructors
CollectionTagger(string, IEnumerable<Ordering>?, ICodeDocument, bool)
Provides a thread-safe ITagger<T> implementation that maintains a simple collection of tagged ranges.
protected CollectionTagger(string key, IEnumerable<Ordering>? orderings, ICodeDocument document, bool isForLanguage)
| Parameter | Type | Description |
|---|---|---|
| key | string | The string-based key that identifies the object. |
| orderings | IEnumerable<Ordering> | The collection of Ordering objects, used to determine how this object is positioned relative to other objects. |
| document | ICodeDocument | The document to which this manager is attached. |
| isForLanguage | bool | Indicates whether this tagger is for a language.
If |
Properties
Count
The number of elements contained in the collection.
this[T]
The tag range that points to the specified tag.
public TagVersionRange<T>? this[T tag] { get; }
| Parameter | Type | Description |
|---|---|---|
| tag | T | The tag for which to search. |
Property Value
Methods
Add(ITextSnapshotLine, T)
Adds a tag range that is associated with a single snapshot line (e.g., a bookmark indicator tag).
public TagVersionRange<T> Add(ITextSnapshotLine snapshotLine, T tag)
| Parameter | Type | Description |
|---|---|---|
| snapshotLine | ITextSnapshotLine | The target ITextSnapshotLine. |
| tag | T | The ITag to add. |
Returns
- TagVersionRange<T>:
The TagVersionRange<T> that was created.
Remarks
The generated ITextVersionRange is created with the DeleteWhenZeroLength and LineBased flags.
Add(TagVersionRange<T>)
Adds a tag range to the collection.
public void Add(TagVersionRange<T> tagRange)
| Parameter | Type | Description |
|---|---|---|
| tagRange | TagVersionRange<T> | The tag range to add to the collection. |
Remarks
This is the lowest-level method used for adding a tag range, and gives the most control over snapshot translation options.
Add(TextSnapshotRange, T)
Adds a tag range that is applied to a snapshot text range (e.g., a breakpoint indicator tag).
public TagVersionRange<T> Add(TextSnapshotRange snapshotRange, T tag)
| Parameter | Type | Description |
|---|---|---|
| snapshotRange | TextSnapshotRange | The target TextSnapshotRange. |
| tag | T | The ITag to add. |
Returns
- TagVersionRange<T>:
The TagVersionRange<T> that was created.
Remarks
The generated ITextVersionRange is created with the DeleteWhenZeroLength flag.
Clear()
Removes all items from the collection.
public void Clear()
Contains(TagVersionRange<T>)
Determines whether the collection contains a specific value.
public bool Contains(TagVersionRange<T> tagRange)
| Parameter | Type | Description |
|---|---|---|
| tagRange | TagVersionRange<T> | The object to locate in the collection. |
Returns
- bool:
trueif the item is found in the collection; otherwise,false.
CopyTo(TagVersionRange<T>[], int)
Copies the entire collection to a compatible one-dimensional Array,
starting at the specified index of the target array.
public void CopyTo(TagVersionRange<T>[] array, int arrayIndex)
| Parameter | Type | Description |
|---|---|---|
| array | TagVersionRange<T>[] | The one-dimensional |
| arrayIndex | int | The zero-based index in |
CreateBatch()
Creates an IDisposable object such that while the object is not disposed, items can be added to this collection without any change events being fired, thereby allowing batch updates to occur.
public IDisposable CreateBatch()
Returns
- IDisposable:
An IDisposable object that, once disposed, will end the batch.
FindNext(ITextSnapshotLine, ITagSearchOptions<T>?)
Finds the next line-based tag (e.g., a bookmark indicator tag), using the specified search options.
public TagVersionRange<T>? FindNext(ITextSnapshotLine snapshotLine, ITagSearchOptions<T>? options)
| Parameter | Type | Description |
|---|---|---|
| snapshotLine | ITextSnapshotLine | The ITextSnapshotLine from which to start the search. |
| options | ITagSearchOptions<T> | The optional ITagSearchOptions<T> that specifies search options. |
Returns
- TagVersionRange<T>:
The TagVersionRange<T> that was found, if any.
FindNext(TextSnapshotOffset, ITagSearchOptions<T>?)
Finds the next text range-based tag (e.g., a breakpoint indicator tag), using the specified search options.
public TagVersionRange<T>? FindNext(TextSnapshotOffset snapshotOffset, ITagSearchOptions<T>? options)
| Parameter | Type | Description |
|---|---|---|
| snapshotOffset | TextSnapshotOffset | The TextSnapshotOffset from which to start the search. |
| options | ITagSearchOptions<T> | The optional ITagSearchOptions<T> that specifies search options. |
Returns
- TagVersionRange<T>:
The TagVersionRange<T> that was found, if any.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<TagVersionRange<T>> GetEnumerator()
Returns
- IEnumerator<TagVersionRange<T>>:
An enumerator that can be used to iterate through the collection.
GetTags(NormalizedTextSnapshotRangeCollection, object?)
Returns the tag ranges that intersect with the specified normalized snapshot ranges.
public override IEnumerable<TagSnapshotRange<T>> GetTags(NormalizedTextSnapshotRangeCollection snapshotRanges, object? parameter)
| Parameter | Type | Description |
|---|---|---|
| snapshotRanges | NormalizedTextSnapshotRangeCollection | The collection of normalized snapshot ranges. |
| parameter | object | An optional parameter that provides contextual information about the tag request. |
Returns
IsTagIncluded(T, TextSnapshotRange, TextSnapshotRange)
Returns whether the specified tag's snapshot range intersects with the target snapshot range, used to determine results for the GetTags(NormalizedTextSnapshotRangeCollection, object?) method.
public virtual bool IsTagIncluded(T tag, TextSnapshotRange tagSnapshotRange, TextSnapshotRange targetSnapshotRange)
| Parameter | Type | Description |
|---|---|---|
| tag | T | The tag to examine. |
| tagSnapshotRange | TextSnapshotRange | The tag's TextSnapshotRange. |
| targetSnapshotRange | TextSnapshotRange | The target TextSnapshotRange. |
Returns
- bool:
trueif there is intersection within the requested snapshot range; otherwise,false.
Remove(TagVersionRange<T>)
Removes the first occurrence of a specific tag range from the collection.
public bool Remove(TagVersionRange<T> tagRange)
| Parameter | Type | Description |
|---|---|---|
| tagRange | TagVersionRange<T> | The tag range to remove from the collection. |
Returns
- bool:
trueif the tag range was successfully removed from the collection; otherwise,false
Remove(T)
Removes a specific tag instance from the collection.
public bool Remove(T tag)
| Parameter | Type | Description |
|---|---|---|
| tag | T | The ITag to remove from the collection. |
Returns
- bool:
trueif the tag was successfully removed from the collection; otherwise,false
RemoveAll(Predicate<TagVersionRange<T>>)
Removes all objects that match the conditions defined by the specified predicate.
public int RemoveAll(Predicate<TagVersionRange<T>> match)
| Parameter | Type | Description |
|---|---|---|
| match | Predicate<TagVersionRange<T>> | The predicate that defines the conditions for removal. |
Returns
- int:
The number of objects that were removed.
Toggle(ITextSnapshotLine, T)
Toggles whether a tag is associated with a single snapshot line (e.g., a bookmark indicator tag).
public TagVersionRange<T>? Toggle(ITextSnapshotLine snapshotLine, T tag)
| Parameter | Type | Description |
|---|---|---|
| snapshotLine | ITextSnapshotLine | The target ITextSnapshotLine. |
| tag | T | The ITag to add, if no tag is already on the line. |
Returns
- TagVersionRange<T>:
The TagVersionRange<T> that was created, if a tag was added.
Toggle(TextSnapshotRange, T)
Toggles whether a tag is associated with a snapshot text range (e.g., a breakpoint indicator tag).
public TagVersionRange<T>? Toggle(TextSnapshotRange snapshotRange, T tag)
| Parameter | Type | Description |
|---|---|---|
| snapshotRange | TextSnapshotRange | The target TextSnapshotRange. |
| tag | T | The ITag to add, if no tag is already in the text range. |
Returns
- TagVersionRange<T>:
The TagVersionRange<T> that was created, if a tag was added.
Events
CollectionChanged
Occurs when the collection changes.
public event NotifyCollectionChangedEventHandler? CollectionChanged
Event Type
Inherited Members
- TaggerBase<T>.ChangeDocument(ICodeDocument)
- TaggerBase<T>.Close()
- TaggerBase<T>.OnClosed()
- TaggerBase<T>.OnTagAggregatorAttached(ITagAggregatorBase)
- TaggerBase<T>.OnTagAggregatorDetached(ITagAggregatorBase)
- TaggerBase<T>.OnTagsChanged(TagsChangedEventArgs)
- TaggerBase<T>.Document
- TaggerBase<T>.Key
- TaggerBase<T>.Orderings
- TaggerBase<T>.Closed
- TaggerBase<T>.TagsChanged
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()