Search Results for

    Show / Hide Table of Contents

    Class Position

    A location in the content being edited.

    Inheritance
    System.Object
    Position
    Implements
    System.ICloneable
    System.IComparable<Position>
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Sdl.DesktopEditor.EditorApi
    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, Int64)

    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

    System.Int64 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
    System.Boolean
    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
    System.Int64

    Methods

    Clone()

    A (shallow) clone of the object.

    Declaration
    public object Clone()
    Returns
    Type Description
    System.Object

    CompareTo(Position)

    Compare to another position.

    Declaration
    public int CompareTo(Position other)
    Parameters
    Type Name Description
    Position other
    Returns
    Type Description
    System.Int32

    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
    System.Object obj
    Returns
    Type Description
    System.Boolean
    Overrides
    System.Object.Equals(System.Object)

    GetAncestors()

    Ordered list of all parent nodes, where the root node is first in the list.

    Declaration
    public List<IAbstractContainerNode> GetAncestors()
    Returns
    Type Description
    System.Collections.Generic.List<IAbstractContainerNode>

    GetHashCode()

    Node hash code combined with the text offet.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    System.Object.GetHashCode()

    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
    System.Boolean

    true if both positions are valid, in the same root container, and the this position is after the other.

    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
    System.Boolean

    true if both positions are valid, in the same root container, and the this position is before the other.

    Implements

    System.ICloneable
    System.IComparable<T>

    Extension Methods

    WindowsControlUtils.ForWindowFromFrameworkElement(Object, Action<Window>)

    On this page

    • Constructors
      • Position()
      • Position(IAbstractContentNode)
      • Position(ITextNode, Int64)
      • Position(Position)
    • Properties
      • IsValid
      • Node
      • TextOffset
    • Methods
      • Clone()
      • CompareTo(Position)
      • Equals(Object)
      • GetAncestors()
      • GetHashCode()
      • IsAfter(Position)
      • IsBefore(Position)
    • Implements
    • Extension Methods
    Back to top Generated by DocFX