TextSnapshotOffset Struct
Represents a zero-based offset value within a certain ITextSnapshot.
public readonly struct TextSnapshotOffset : IComparable<TextSnapshotOffset>, IComparable<int>, IEquatable<TextSnapshotOffset>, ITextRangeProvider
- Implements:
- IComparable<TextSnapshotOffset> IComparable<int> IEquatable<TextSnapshotOffset> ITextRangeProvider
Constructors
TextSnapshotOffset(ITextSnapshot, int)
Represents a zero-based offset value within a certain ITextSnapshot.
public TextSnapshotOffset(ITextSnapshot snapshot, int offset)
| Parameter | Type | Description |
|---|---|---|
| snapshot | ITextSnapshot | The ITextSnapshot that contains the offset. |
| offset | int | The zero-based offset. |
Properties
Column
The zero-based column value, which accounts for the document's tab size.
Line
The ITextSnapshotLine that contains the offset.
Offset
The zero-based offset value.
Position
The TextPosition for the offset.
Snapshot
The ITextSnapshot that contains the offset.
Methods
CompareTo(TextSnapshotOffset)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(TextSnapshotOffset snapshotOffset)
| Parameter | Type | Description |
|---|---|---|
| snapshotOffset | TextSnapshotOffset |
Returns
- int:
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
CompareTo(int)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(int value)
| Parameter | Type | Description |
|---|---|---|
| value | int |
Returns
- int:
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
Equals(TextSnapshotOffset)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(TextSnapshotOffset other)
| Parameter | Type | Description |
|---|---|---|
| other | TextSnapshotOffset | An object to compare with this object. |
Returns
- bool:
trueif the current object is equal to theotherparameter; otherwise,false.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
| Parameter | Type | Description |
|---|---|---|
| obj | object | The object to compare with the current instance. |
Returns
- bool:
trueifobjand this instance are the same type and represent the same value; otherwise,false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int:
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns the string representation of this object.
TranslateTo(ITextSnapshot, TextOffsetTrackingMode)
Translates this offset from one ITextSnapshot to another in the same ITextDocument.
public TextSnapshotOffset TranslateTo(ITextSnapshot toSnapshot, TextOffsetTrackingMode trackingMode)
| Parameter | Type | Description |
|---|---|---|
| toSnapshot | ITextSnapshot | The ITextSnapshot that is the target of the translation. |
| trackingMode | TextOffsetTrackingMode | A TextOffsetTrackingMode indicating the tracking mode to use. |
Returns
- TextSnapshotOffset:
The translated TextSnapshotOffset.
Operators
operator ==(TextSnapshotOffset, TextSnapshotOffset)
Compares two TextSnapshotOffset objects. The result specifies whether the values of the Offset properties of the two TextSnapshotOffset objects are equal.
public static bool operator ==(TextSnapshotOffset left, TextSnapshotOffset right)
| Parameter | Type | Description |
|---|---|---|
| left | TextSnapshotOffset | A TextSnapshotOffset to compare. |
| right | TextSnapshotOffset | A TextSnapshotOffset to compare. |
Returns
operator >(TextSnapshotOffset, TextSnapshotOffset)
Compares whether one TextSnapshotOffset is greater than the other.
public static bool operator >(TextSnapshotOffset left, TextSnapshotOffset right)
| Parameter | Type | Description |
|---|---|---|
| left | TextSnapshotOffset | A TextSnapshotOffset to compare. |
| right | TextSnapshotOffset | A TextSnapshotOffset to compare. |
Returns
- bool:
trueif the TextSnapshotOffset inleftis greater than the TextSnapshotOffset inright; otherwise,false.
operator >=(TextSnapshotOffset, TextSnapshotOffset)
Compares whether one TextSnapshotOffset is greater than or equal to the other.
public static bool operator >=(TextSnapshotOffset left, TextSnapshotOffset right)
| Parameter | Type | Description |
|---|---|---|
| left | TextSnapshotOffset | A TextSnapshotOffset to compare. |
| right | TextSnapshotOffset | A TextSnapshotOffset to compare. |
Returns
- bool:
trueif the TextSnapshotOffset inleftis greater than or equal to the TextSnapshotOffset inright; otherwise,false.
implicit operator int(TextSnapshotOffset)
Implicitly converts a TextSnapshotOffset instance to an integer offset.
public static implicit operator int(TextSnapshotOffset snapshotOffset)
| Parameter | Type | Description |
|---|---|---|
| snapshotOffset | TextSnapshotOffset | The TextSnapshotOffset to convert. |
Returns
- int:
The integer offset result.
operator !=(TextSnapshotOffset, TextSnapshotOffset)
Compares two TextSnapshotOffset objects. The result specifies whether the values of the Offset properties of the two TextSnapshotOffset objects are unequal.
public static bool operator !=(TextSnapshotOffset left, TextSnapshotOffset right)
| Parameter | Type | Description |
|---|---|---|
| left | TextSnapshotOffset | A TextSnapshotOffset to compare. |
| right | TextSnapshotOffset | A TextSnapshotOffset to compare. |
Returns
operator <(TextSnapshotOffset, TextSnapshotOffset)
Compares whether one TextSnapshotOffset is less than the other.
public static bool operator <(TextSnapshotOffset left, TextSnapshotOffset right)
| Parameter | Type | Description |
|---|---|---|
| left | TextSnapshotOffset | A TextSnapshotOffset to compare. |
| right | TextSnapshotOffset | A TextSnapshotOffset to compare. |
Returns
- bool:
trueif the TextSnapshotOffset inleftis less than the TextSnapshotOffset inright; otherwise,false.
operator <=(TextSnapshotOffset, TextSnapshotOffset)
Compares whether one TextSnapshotOffset is less than or equal to the other.
public static bool operator <=(TextSnapshotOffset left, TextSnapshotOffset right)
| Parameter | Type | Description |
|---|---|---|
| left | TextSnapshotOffset | A TextSnapshotOffset to compare. |
| right | TextSnapshotOffset | A TextSnapshotOffset to compare. |
Returns
- bool:
trueif the TextSnapshotOffset inleftis less than or equal to the TextSnapshotOffset inright; otherwise,false.