Class ContentRange
Represents a mutable range of text in a document story.
Inherited Members
Namespace: DRIT.Document
Assembly: DRIT.Document.dll
Syntax
public sealed class ContentRange
Constructors
ContentRange(ContentPosition, ContentPosition)
Initializes a range between two positions in the same document story.
Declaration
public ContentRange(ContentPosition start, ContentPosition end)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentPosition | start | The inclusive start position. |
| ContentPosition | end | The exclusive end position. |
Properties
End
Gets the exclusive end position.
Declaration
public ContentPosition End { get; }
Property Value
| Type | Description |
|---|---|
| ContentPosition |
Length
Gets the number of characters in the range.
Declaration
public int Length { get; }
Property Value
| Type | Description |
|---|---|
| int |
SpansParagraphBoundary
Gets a value indicating whether the range contains a paragraph separator.
Declaration
public bool SpansParagraphBoundary { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Start
Gets the inclusive start position.
Declaration
public ContentPosition Start { get; }
Property Value
| Type | Description |
|---|---|
| ContentPosition |
Text
Gets the current text covered by the range.
Declaration
public string Text { get; }
Property Value
| Type | Description |
|---|---|
| string |
Value
Gets the current range text as a compatibility alias for Text.
Declaration
public string Value { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Delete()
Deletes the text covered by the range.
Declaration
public void Delete()
Find(string)
Finds non-overlapping occurrences of text within the range.
Declaration
public IEnumerable<ContentRange> Find(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to find. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ContentRange> | The matching content ranges. |
Find(string, FindReplaceOptions)
Finds occurrences of a string within the range using the specified options.
Declaration
public IEnumerable<ContentRange> Find(string text, FindReplaceOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The literal or regular expression pattern to find. |
| FindReplaceOptions | options | The find options, or null for the defaults. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ContentRange> | The matching content ranges. |
Find(string, StringComparison)
Finds non-overlapping occurrences of text within the range using the specified comparison.
Declaration
public IEnumerable<ContentRange> Find(string text, StringComparison comparisonType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to find. |
| StringComparison | comparisonType | The comparison used to find the text. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ContentRange> | The matching content ranges. |
Find(Regex)
Finds occurrences of a regular expression within the range.
Declaration
public IEnumerable<ContentRange> Find(Regex regex)
Parameters
| Type | Name | Description |
|---|---|---|
| Regex | regex | The regular expression to find. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ContentRange> | The matching content ranges. |
Find(Regex, FindReplaceOptions)
Finds occurrences of a regular expression within the range using the specified options.
Declaration
public IEnumerable<ContentRange> Find(Regex regex, FindReplaceOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| Regex | regex | The regular expression to find. |
| FindReplaceOptions | options | The find options, or null for the defaults. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ContentRange> | The matching content ranges. |
InsertRange(ContentRange)
Inserts the text of another range at this range's end position.
Declaration
public ContentRange InsertRange(ContentRange range)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentRange | range | The range whose text should be inserted. |
Returns
| Type | Description |
|---|---|
| ContentRange | This range. |
LoadText(string)
Replaces the range with plain text.
Declaration
public ContentRange LoadText(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The replacement text. |
Returns
| Type | Description |
|---|---|
| ContentRange | This updated range. |
Replace(string, string)
Replaces all ordinal matches within the range.
Declaration
public int Replace(string oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The text to replace. |
| string | newValue | The replacement text. |
Returns
| Type | Description |
|---|---|
| int | The number of replacements performed. |
Replace(string, string, FindReplaceOptions)
Replaces matches within the range using the specified options.
Declaration
public int Replace(string oldValue, string newValue, FindReplaceOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The literal or regular expression pattern to replace. |
| string | newValue | The replacement text. |
| FindReplaceOptions | options | The replacement options, or null for the defaults. |
Returns
| Type | Description |
|---|---|
| int | The number of replacements performed. |
Replace(string, string, StringComparison)
Replaces all matches within the range using the specified comparison.
Declaration
public int Replace(string oldValue, string newValue, StringComparison comparisonType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The text to replace. |
| string | newValue | The replacement text. |
| StringComparison | comparisonType | The comparison used to find matches. |
Returns
| Type | Description |
|---|---|
| int | The number of replacements performed. |
Replace(Regex, string)
Replaces regular expression matches within the range.
Declaration
public int Replace(Regex regex, string replacement)
Parameters
| Type | Name | Description |
|---|---|---|
| Regex | regex | The regular expression pattern to replace. |
| string | replacement | The replacement text. |
Returns
| Type | Description |
|---|---|
| int | The number of replacements performed. |
Replace(Regex, string, FindReplaceOptions)
Replaces regular expression matches within the range using the specified options.
Declaration
public int Replace(Regex regex, string replacement, FindReplaceOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| Regex | regex | The regular expression pattern to replace. |
| string | replacement | The replacement text. |
| FindReplaceOptions | options | The replacement options, or null for the defaults. |
Returns
| Type | Description |
|---|---|
| int | The number of replacements performed. |
ToString()
Returns the current range text.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The current range text. |