Table of Contents

Class TextEdit

Namespace
NMF.AnyText
Assembly
NMF.AnyText.Core.dll

Denotes an edit for text

public class TextEdit : IEquatable<TextEdit>
Inheritance
TextEdit
Implements
Inherited Members

Constructors

TextEdit(ParsePosition, ParsePosition, string[])

Creates a new text edit

public TextEdit(ParsePosition start, ParsePosition end, string[] newText)

Parameters

start ParsePosition

the start of the edit

end ParsePosition

the end of the edit

newText string[]

the new text inserted between start and end

Exceptions

ArgumentException

thrown if start is after end

Properties

End

Gets the end of the edit

public ParsePosition End { get; }

Property Value

ParsePosition

EndAfterEdit

Gets the end position after the edit has been applied

public ParsePosition EndAfterEdit { get; }

Property Value

ParsePosition

NewText

Gets the new text inserted between start and end

public string[] NewText { get; }

Property Value

string[]

Start

Gets the start of the edit

public ParsePosition Start { get; }

Property Value

ParsePosition

Methods

AdjustPosition(ParsePosition)

Adjusts the given position due to the current text edit

public ParsePosition AdjustPosition(ParsePosition position)

Parameters

position ParsePosition

the incoming position

Returns

ParsePosition

the position after the text edit has been applied. Throws if the position is inside the text edit

AdjustPosition(ParsePosition, bool)

Adjusts the given position due to the current text edit

public ParsePosition AdjustPosition(ParsePosition position, bool throwIfInvalid)

Parameters

position ParsePosition

the incoming position

throwIfInvalid bool

if true, an exception is thrown if the position is inside the edit. Otherwise, the end of the edit is returned.

Returns

ParsePosition

the position after the text edit has been applied.

Apply(string[])

Applies the text edit to the given input

public string[] Apply(string[] input)

Parameters

input string[]

an input array of string lines

Returns

string[]

a text array including the changes

Equals(TextEdit)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(TextEdit other)

Parameters

other TextEdit

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

UpdatePosition(ref ParsePosition)

Updates the position after applying this edit. Only Updates the Postion if it is fully after the Edit.

public void UpdatePosition(ref ParsePosition position)

Parameters

position ParsePosition

The position to update.