TextSnapshotRange Struct
Represents a zero-based range of two normalized offset values within a certain ITextSnapshot.
public struct TextSnapshotRange : ITextPositionRangeProvider, ITextRangeProvider
- Implements:
- ITextPositionRangeProvider ITextRangeProvider
Constructors
TextSnapshotRange(ITextSnapshot, TextRange)
Initializes a new instance of the TextSnapshotRange
class with the specified TextRange.
public TextSnapshotRange(ITextSnapshot snapshot, TextRange textRange)
Parameter | Type | Description |
---|---|---|
snapshot | ITextSnapshot | The ITextSnapshot that contains the text range. |
textRange | TextRange | The TextRange of the range. |
TextSnapshotRange(ITextSnapshot, Int32)
Initializes a new instance of the TextSnapshotRange
class using the specified offset for both the start and end values.
public TextSnapshotRange(ITextSnapshot snapshot, int offset)
Parameter | Type | Description |
---|---|---|
snapshot | ITextSnapshot | The ITextSnapshot that contains the text range. |
offset | System.Int32 | The start and end offset in the range. |
TextSnapshotRange(ITextSnapshot, Int32, Int32)
Initializes a new instance of the TextSnapshotRange
class with the specified offset values.
public TextSnapshotRange(ITextSnapshot snapshot, int startOffset, int endOffset)
Parameter | Type | Description |
---|---|---|
snapshot | ITextSnapshot | The ITextSnapshot that contains the text range. |
startOffset | System.Int32 | The start offset in the range. |
endOffset | System.Int32 | The end offset in the range. |
TextSnapshotRange(TextSnapshotOffset)
Initializes a new instance of the TextSnapshotRange
class using the specified TextSnapshotOffset for both the start and end values.
public TextSnapshotRange(TextSnapshotOffset snapshotOffset)
Parameter | Type | Description |
---|---|---|
snapshotOffset | TextSnapshotOffset | The start and end offset in the range. |
Properties
AbsoluteLength
Gets the absolute number of characters encompassed by the TextSnapshotRange.
public int AbsoluteLength { get; }
Property Value
- System.Int32:
The absolute number of characters encompassed by the TextSnapshotRange.
Remarks
This value will always return a positive length, even if the range is not normalized.
Deleted
Gets a TextSnapshotRange that has no Snapshot and is flagged as deleted.
public static TextSnapshotRange Deleted { get; }
Property Value
- TextSnapshotRange:
A TextSnapshotRange that has no Snapshot and is flagged as deleted.
EndLine
Gets the ITextSnapshotLine that contains the end offset in the text range.
public ITextSnapshotLine EndLine { get; }
Property Value
- ITextSnapshotLine:
The ITextSnapshotLine that contains the end offset in the text range.
EndOffset
Gets the end offset in the range.
public int EndOffset { get; }
Property Value
- System.Int32:
The end offset in the range.
Remarks
Since snapshot ranges are normalized, this property returns the last offset in the range.
EndPosition
Gets the end TextPosition in the range.
public TextPosition EndPosition { get; }
Property Value
- TextPosition:
The end TextPosition in the range.
Remarks
Since snapshot ranges are normalized, this property returns the last TextPosition in the range.
IsDeleted
Gets whether the range has been flagged as deleted.
public bool IsDeleted { get; }
Property Value
- System.Boolean:
true
if the range has been flagged as deleted; otherwise,false
.
IsZeroLength
Gets whether the range has a zero length.
public bool IsZeroLength { get; }
Property Value
- System.Boolean:
true
if the range has a zero length; otherwise,false
.
Length
Gets the number of characters encompassed by the TextSnapshotRange.
public int Length { get; }
Property Value
- System.Int32:
The number of characters encompassed by the TextSnapshotRange.
Remarks
This value will return a negative length if the range is not normalized.
PositionRange
Gets a TextPositionRange that specifies the text position range of the object.
public TextPositionRange PositionRange { get; }
Property Value
- TextPositionRange:
A TextPositionRange that specifies the text position range of the object.
Snapshot
Gets the ITextSnapshot that contains the text range.
public ITextSnapshot Snapshot { get; }
Property Value
- ITextSnapshot:
The ITextSnapshot that contains the text range.
StartLine
Gets the ITextSnapshotLine that contains the start offset in the text range.
public ITextSnapshotLine StartLine { get; }
Property Value
- ITextSnapshotLine:
The ITextSnapshotLine that contains the start offset in the text range.
StartOffset
Gets the start offset in the range.
public int StartOffset { get; }
Property Value
- System.Int32:
The start offset in the range.
Remarks
Since snapshot ranges are normalized, this property returns the first offset in the range.
StartPosition
Gets the start TextPosition in the range.
public TextPosition StartPosition { get; }
Property Value
- TextPosition:
The start TextPosition in the range.
Remarks
Since snapshot ranges are normalized, this property returns the first TextPosition in the range.
Text
Gets the snapshot text substring encompassed by this range, using CarriageReturnNewline for line ends.
public string Text { get; }
Property Value
- System.String:
The snapshot text substring encompassed by this range, using CarriageReturnNewline for line ends.
TextRange
Gets a TextRange that specifies the text range of the object.
public TextRange TextRange { get; }
Property Value
Methods
BordersOn(TextRange)
Returns whether the TextSnapshotRange borders on, but does not overlap the specified TextRange.
public bool BordersOn(TextRange range)
Parameter | Type | Description |
---|---|---|
range | TextRange | The TextRange to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange borders on, but does not overlap the specified TextRange; otherwise,false
.
BordersOn(TextSnapshotRange)
Returns whether the TextSnapshotRange borders on, but does not overlap the specified TextSnapshotRange.
public bool BordersOn(TextSnapshotRange range)
Parameter | Type | Description |
---|---|---|
range | TextSnapshotRange | The TextSnapshotRange to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange borders on, but does not overlap the specified TextSnapshotRange; otherwise,false
.
BordersOn(Int32)
Returns whether the TextSnapshotRange borders on the specified offset.
public bool BordersOn(int offset)
Parameter | Type | Description |
---|---|---|
offset | System.Int32 | The offset to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange borders on the specified offset; otherwise,false
.
Remarks
This method checks to see if the specified offset is either the StartOffset or EndOffset.
CompareTo(TextRange)
Compares the current instance with another object of the same type.
public int CompareTo(TextRange range)
Parameter | Type | Description |
---|---|---|
range | TextRange | A TextRange to compare with this instance. |
Returns
- System.Int32:
A 32-bit signed integer that indicates the relative order of the comparands.
CompareTo(TextSnapshotRange)
Compares the current instance with another object of the same type.
public int CompareTo(TextSnapshotRange range)
Parameter | Type | Description |
---|---|---|
range | TextSnapshotRange | A TextSnapshotRange to compare with this instance. |
Returns
- System.Int32:
A 32-bit signed integer that indicates the relative order of the comparands.
Contains(TextRange)
Returns whether the TextSnapshotRange contains the specified TextRange.
public bool Contains(TextRange range)
Parameter | Type | Description |
---|---|---|
range | TextRange | The TextRange to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange contains the specified TextRange; otherwise,false
.
Contains(TextSnapshotRange)
Returns whether the TextSnapshotRange contains the specified TextSnapshotRange.
public bool Contains(TextSnapshotRange range)
Parameter | Type | Description |
---|---|---|
range | TextSnapshotRange | The TextSnapshotRange to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange contains the specified TextSnapshotRange; otherwise,false
.
Contains(Int32)
Returns whether the TextSnapshotRange contains the specified offset.
public bool Contains(int offset)
Parameter | Type | Description |
---|---|---|
offset | System.Int32 | The offset to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange contains the specified offset; otherwise,false
.
Remarks
This method returns false
if the offset falls on the EndOffset offset
since this method indicates if the offset is encompassed by the TextSnapshotRange.
Equals(Object)
Determines whether the specified Object
is equal to the current Object
.
public override bool Equals(object obj)
Parameter | Type | Description |
---|---|---|
obj | System.Object | The |
Returns
- System.Boolean:
true
if the specifiedObject
is equal to the currentObject
; otherwise,false
.
FromSpan(ITextSnapshot, Int32, Int32)
Returns a TextSnapshotRange that covers the specified offset and length.
public static TextSnapshotRange FromSpan(ITextSnapshot snapshot, int offset, int length)
Parameter | Type | Description |
---|---|---|
snapshot | ITextSnapshot | The ITextSnapshot that contains the text range. |
offset | System.Int32 | The start offset. |
length | System.Int32 | The length of the range. |
Returns
- TextSnapshotRange:
The TextSnapshotRange that was created.
GetHashCode()
Returns a hash code for this object.
public override int GetHashCode()
Returns
- System.Int32:
An integer value that specifies a hash value for this object.
GetText(LineTerminator)
Returns the snapshot text substring encompassed by this range, using the specified LineTerminator for line ends.
public string GetText(LineTerminator lineTerminator)
Parameter | Type | Description |
---|---|---|
lineTerminator | LineTerminator | A LineTerminator specifying the type of line terminators to use. |
Returns
- System.String:
The snapshot text substring encompassed by this range, using the specified LineTerminator for line ends.
IntersectsWith(TextRange)
Returns whether the TextSnapshotRange intersects with the specified TextRange.
public bool IntersectsWith(TextRange range)
Parameter | Type | Description |
---|---|---|
range | TextRange | The TextRange to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange intersects with the specified TextRange; otherwise,false
.
Remarks
This method returns whether the specified TextRange borders on or overlaps the TextSnapshotRange.
IntersectsWith(TextSnapshotRange)
Returns whether the TextSnapshotRange intersects with the specified TextSnapshotRange.
public bool IntersectsWith(TextSnapshotRange range)
Parameter | Type | Description |
---|---|---|
range | TextSnapshotRange | The TextSnapshotRange to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange intersects with the specified TextSnapshotRange; otherwise,false
.
Remarks
This method returns whether the specified TextSnapshotRange borders on or overlaps the TextSnapshotRange.
IntersectsWith(TextSnapshotRange, Boolean, Boolean)
Returns whether the TextSnapshotRange intersects with the specified TextSnapshotRange.
public bool IntersectsWith(TextSnapshotRange range, bool includeFirstEdge, bool includeLastEdge)
Parameter | Type | Description |
---|---|---|
range | TextSnapshotRange | The TextSnapshotRange to examine. |
includeFirstEdge | System.Boolean | Whether to return |
includeLastEdge | System.Boolean | Whether to return |
Returns
- System.Boolean:
true
if the TextSnapshotRange intersects with the specified TextSnapshotRange; otherwise,false
.
Remarks
This method returns whether the specified TextSnapshotRange borders on or overlaps the TextSnapshotRange.
IntersectsWith(Int32)
Returns whether the TextSnapshotRange intersects with the specified offset.
public bool IntersectsWith(int offset)
Parameter | Type | Description |
---|---|---|
offset | System.Int32 | The offset to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange intersects with the specified offset; otherwise,false
.
Remarks
This method returns whether the specified offset borders on or lies within the TextSnapshotRange.
OverlapsWith(TextRange)
Returns whether the TextSnapshotRange overlaps with, or crosses, the specified TextRange.
public bool OverlapsWith(TextRange range)
Parameter | Type | Description |
---|---|---|
range | TextRange | The TextRange to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange overlaps with, or crosses, the specified TextRange; otherwise,false
.
OverlapsWith(TextSnapshotRange)
Returns whether the TextSnapshotRange overlaps with, or crosses, the specified TextSnapshotRange.
public bool OverlapsWith(TextSnapshotRange range)
Parameter | Type | Description |
---|---|---|
range | TextSnapshotRange | The TextSnapshotRange to examine. |
Returns
- System.Boolean:
true
if the TextSnapshotRange overlaps with, or crosses, the specified TextSnapshotRange; otherwise,false
.
ToString()
Converts the object to a String
.
public override string ToString()
Returns
- System.String:
A string whose value represents this object.
ToVersionRange(TextRangeTrackingModes)
Converts this text range into an ITextVersionRange.
public ITextVersionRange ToVersionRange(TextRangeTrackingModes trackingModes)
Parameter | Type | Description |
---|---|---|
trackingModes | TextRangeTrackingModes | A TextRangeTrackingModes indicating the tracking modes to use. |
Returns
- ITextVersionRange:
The ITextVersionRange that was created.
ToVersionRange(Func<TextRangeTrackingModes>)
Converts this text range into an ITextVersionRange.
public ITextVersionRange ToVersionRange(Func<TextRangeTrackingModes> trackingModesFunc)
Parameter | Type | Description |
---|---|---|
trackingModesFunc | System.Func<TextRangeTrackingModes> | A function that dynamically returns a TextRangeTrackingModes indicating the tracking modes to use. |
Returns
- ITextVersionRange:
The ITextVersionRange that was created.
TranslateTo(ITextSnapshot, TextRangeTrackingModes)
Translates this text range from one ITextSnapshot to another in the same ITextDocument.
public TextSnapshotRange TranslateTo(ITextSnapshot toSnapshot, TextRangeTrackingModes trackingModes)
Parameter | Type | Description |
---|---|---|
toSnapshot | ITextSnapshot | The ITextSnapshot that is the target of the translation. |
trackingModes | TextRangeTrackingModes | A TextRangeTrackingModes indicating the tracking modes to use. |
Returns
- TextSnapshotRange:
The translated TextSnapshotRange.
Operators
Equality(TextSnapshotRange, TextSnapshotRange)
Compares two TextSnapshotRange objects. The result specifies whether the values of the StartOffset and EndOffset properties of the two TextSnapshotRange objects are equal.
public static bool operator ==(TextSnapshotRange left, TextSnapshotRange right)
Parameter | Type | Description |
---|---|---|
left | TextSnapshotRange | A TextSnapshotRange to compare. |
right | TextSnapshotRange | A TextSnapshotRange to compare. |
Returns
- System.Boolean:
true
if the StartOffset and EndOffset values ofleft
andright
are equal; otherwise,false
.
GreaterThan(TextSnapshotRange, TextSnapshotRange)
Compares whether one TextSnapshotRange is greater than the other.
public static bool operator>(TextSnapshotRange left, TextSnapshotRange right)
Parameter | Type | Description |
---|---|---|
left | TextSnapshotRange | A TextSnapshotRange to compare. |
right | TextSnapshotRange | A TextSnapshotRange to compare. |
Returns
- System.Boolean:
true
if the TextSnapshotRange inleft
is greater than the TextSnapshotRange inright
; otherwise,false
.
Implicit(TextSnapshotRange to TextRange)
Implicitly converts a TextSnapshotRange instance to a TextRange.
public static implicit operator TextRange(TextSnapshotRange range)
Parameter | Type | Description |
---|---|---|
range | TextSnapshotRange | The TextSnapshotRange to convert. |
Returns
Inequality(TextSnapshotRange, TextSnapshotRange)
Compares two TextSnapshotRange objects. The result specifies whether the values of the StartOffset and EndOffset properties of the two TextSnapshotRange objects are unequal.
public static bool operator !=(TextSnapshotRange left, TextSnapshotRange right)
Parameter | Type | Description |
---|---|---|
left | TextSnapshotRange | A TextSnapshotRange to compare. |
right | TextSnapshotRange | A TextSnapshotRange to compare. |
Returns
- System.Boolean:
true
if the StartOffset and EndOffset values ofleft
andright
are unequal; otherwise,false
.
LessThan(TextSnapshotRange, TextSnapshotRange)
Compares whether one TextSnapshotRange is less than the other.
public static bool operator <(TextSnapshotRange left, TextSnapshotRange right)
Parameter | Type | Description |
---|---|---|
left | TextSnapshotRange | A TextSnapshotRange to compare. |
right | TextSnapshotRange | A TextSnapshotRange to compare. |
Returns
- System.Boolean:
true
if the TextSnapshotRange inleft
is less than the TextSnapshotRange inright
; otherwise,false
.
Explicit Interface Implementations
ITextPositionRangeProvider.PositionRange
Gets or sets a TextPositionRange that specifies the text position range of the object.
TextPositionRange ITextPositionRangeProvider.PositionRange { get; set; }
Returns
- TextPositionRange:
A TextPositionRange that specifies the text position range of the object.
ITextRangeProvider.TextRange
Gets or sets a TextRange that specifies the text range of the object.
TextRange ITextRangeProvider.TextRange { get; set; }
Returns
Inherited Members
- System.Object.Equals(System.Object, System.Object)
- System.Object.ReferenceEquals(System.Object, System.Object)
- System.Object.GetType()