Class Position
A location in the content being edited.
Inherited Members
Namespace: SdlSdl.DesktopEditorEditorApi
Assembly: Sdl.DesktopEditor.EditorApi.dll
Syntax
public class Position : ICloneable, IComparable<Position>
Constructors
Position()
Constructs an uninitialized position.
Declaration
public Position()
Remarks
The object is not considered valid until a node has been set.
Position(IAbstractContentNode)
Constructs a position that references a node.
Declaration
public Position(IAbstractContentNode node)
Parameters
Type | Name | Description |
---|---|---|
IAbstractContentNode | node | The node. |
Remarks
Use this constructor for position that are not inside text nodes.
Position(ITextNode, long)
Constructs a position that references a location inside a text node.
Declaration
public Position(ITextNode node, long textOffset)
Parameters
Type | Name | Description |
---|---|---|
ITextNode | node | the text node |
long | textOffset | 0-based offset in the text of the text node. |
Position(Position)
Construct a position that has the same values as another position object.
Declaration
public Position(Position other)
Parameters
Type | Name | Description |
---|---|---|
Position | other |
Properties
IsValid
Indicates whether the position is valid or not.
Declaration
public virtual bool IsValid { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The position is not valid if the node is null, if the text offset is negative, if the text offset is non-zero for a non-text node or if the text offset is greater or equal to the length of the node.
Node
The node this position references, or null
if the position is not valid.
Declaration
public IAbstractContentNode Node { get; set; }
Property Value
Type | Description |
---|---|
IAbstractContentNode |
TextOffset
The 0-based offset into the text in the text node.
Declaration
public long TextOffset { get; set; }
Property Value
Type | Description |
---|---|
long |
Methods
Clone()
A (shallow) clone of the object.
Declaration
public object Clone()
Returns
Type | Description |
---|---|
object |
CompareTo(Position)
Compare to another position.
Declaration
public int CompareTo(Position other)
Parameters
Type | Name | Description |
---|---|---|
Position | other |
Returns
Type | Description |
---|---|
int | 1 if the other position appears before this one, 0 if they are equal or -1 if this position appears before the other. |
Remarks
If the other position is null
it is considered "before".
If both positions are invalid they are considered "equal".
If one position is valid and the other not, the invalid position is considered "before" (similar to a null comparison).
If both positions are valid but do not appear in the same root container they cannot be compared, in which case an exception is thrown.
Equals(object)
True if referring to the same node and text offset.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj |
Returns
Type | Description |
---|---|
bool |
Overrides
GetAncestors()
Ordered list of all parent nodes, where the root node is first in the list.
Declaration
public List<IAbstractContainerNode> GetAncestors()
Returns
Type | Description |
---|---|
ListIAbstractContainerNode |
GetHashCode()
Node hash code combined with the text offet.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
IsAfter(Position)
Compare two positions to determine if this is after the other.
Declaration
public bool IsAfter(Position other)
Parameters
Type | Name | Description |
---|---|---|
Position | other |
Returns
Type | Description |
---|---|
bool |
|
IsBefore(Position)
Compare two positions to determine if this is before the other.
Declaration
public bool IsBefore(Position other)
Parameters
Type | Name | Description |
---|---|---|
Position | other |
Returns
Type | Description |
---|---|
bool |
|