Show / Hide Table of Contents

Class TextInteractor

Defines the TextInteractor.

Inheritance
System.Object
TextFile
TextInteractor
Inherited Members
TextFile.FilePath
TextFile.Opened
TextFile.Logger
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: TextInteractor
Assembly: TextInteractor.dll
Syntax
public class TextInteractor : TextFile

Constructors

| Improve this Doc View Source

TextInteractor(String)

Initializes a new instance of the TextInteractor class.

Declaration
public TextInteractor(string filePath)
Parameters
Type Name Description
System.String filePath

The path to the textFile.

| Improve this Doc View Source

TextInteractor(String, ILogger)

Initializes a new instance of the TextInteractor class.

Declaration
public TextInteractor(string filePath, ILogger logger)
Parameters
Type Name Description
System.String filePath

The path to the textFile.

Microsoft.Extensions.Logging.ILogger logger

Logger that is passed in.

Methods

| Improve this Doc View Source

AddLine(String)

This method appends a line to the end of the text file.

Declaration
public void AddLine(string contents)
Parameters
Type Name Description
System.String contents

The string to be added to the end of the file.

| Improve this Doc View Source

Close()

This method closes the text file for reading and writing. If file not open, nothing will happen.

Declaration
public override bool Close()
Returns
Type Description
System.Boolean
true
if the text file successfully closes.
Overrides
TextFile.Close()
| Improve this Doc View Source

Compare(TextFile, String, Boolean, Boolean)

This method compares the text file with another text file.

Declaration
public override bool Compare(TextFile txtFile, string resultFilePath, bool ignoreWhitespace = false, bool caseInsensitive = false)
Parameters
Type Name Description
TextFile txtFile

Text file to compare.

System.String resultFilePath

Text file that shows the comparison result when different. If there is a file name conflict, we will replace the file.

System.Boolean ignoreWhitespace

Set to true if we are going to ignore whitespace during comparison. Default is false.

System.Boolean caseInsensitive

Set to true if we are going to perform case insensitive comparison. Default is false.

Returns
Type Description
System.Boolean
true
if the contents of the text files match.
Overrides
TextFile.Compare(TextFile, String, Boolean, Boolean)
| Improve this Doc View Source

Compare(TextFile, String, Int32, Int32, Int32, Int32, Boolean, Boolean)

This method compares the text file with another text file specifying the top left and bottom right coordinates. If we consider the file to be a 2D matrix of characters, the startingLine and startingIndex would be the top left corner (x, y) respectively. The endingLine and endingIndex would be the bottom right coordinate on the bottom right corner.

Declaration
public override bool Compare(TextFile txtFile, string resultFilePath, int startingLine, int startingIndex, int endingLine, int endingIndex, bool ignoreWhitespace = false, bool caseInsensitive = false)
Parameters
Type Name Description
TextFile txtFile

The textfile that you want to compare with.TextFile.

System.String resultFilePath

Text file that shows the comparison result when different.

System.Int32 startingLine

The line index to start the comparison.System.Int32.

System.Int32 startingIndex

The character index to start the comparison.System.Int32.

System.Int32 endingLine

The line index to stop the comparison.System.Int32.

System.Int32 endingIndex

The character index to end the comparison.System.Int32.

System.Boolean ignoreWhitespace

Set to true if we are going to ignore whitespace during comparison. Default is false.

System.Boolean caseInsensitive

Set to true if we are going to perform case insensitive comparison. Default is false.

Returns
Type Description
System.Boolean
true
if the contents of the text file match.
Overrides
TextFile.Compare(TextFile, String, Int32, Int32, Int32, Int32, Boolean, Boolean)
| Improve this Doc View Source

Find(String)

Find if string exist or not.

Declaration
public bool Find(string expectedString)
Parameters
Type Name Description
System.String expectedString

The string to be found.System.String.

Returns
Type Description
System.Boolean
true
if expectedString is foundSystem.Boolean.
| Improve this Doc View Source

Find(String, Int32)

This method tries to find the expected string in the specified line.

Declaration
public override bool Find(string expectedString, int lineNum)
Parameters
Type Name Description
System.String expectedString

String to be found.

System.Int32 lineNum
Returns
Type Description
System.Boolean
true
if the expected string is found at line.
Overrides
TextFile.Find(String, Int32)
| Improve this Doc View Source

FindAndCount(String)

The FindAndCount.

Declaration
public int FindAndCount(string expectedString)
Parameters
Type Name Description
System.String expectedString

The string to be found and counted.System.String.

Returns
Type Description
System.Int32

The count of the expectedString in file System.Int32.

| Improve this Doc View Source

FinishedReading()

This methods returns whether or not the reader is at the end of the text file.

Declaration
public override bool FinishedReading()
Returns
Type Description
System.Boolean
true
if the file has been finished reading.
Overrides
TextFile.FinishedReading()
| Improve this Doc View Source

LineExactMatch(String, Int32)

The LineExactMatch.

Declaration
public bool LineExactMatch(string expectedString, int lineNum)
Parameters
Type Name Description
System.String expectedString

The expected string value of the corresponding line number.System.String.

System.Int32 lineNum

The line numberSystem.Int32.

Returns
Type Description
System.Boolean

The System.Boolean.

| Improve this Doc View Source

Modify(Int32, String)

This methods modifies the textfile by replacing text in the text file.

Declaration
public override bool Modify(int replaceType, string args)
Parameters
Type Name Description
System.Int32 replaceType

0 means to replace once, 1 means to replaceAll, 2 means to replaceLine,3 means to replace regexSystem.Int32.

System.String args

The argsSystem.String.

Returns
Type Description
System.Boolean
true
if the modification was successful. System.Boolean.
Overrides
TextFile.Modify(Int32, String)
| Improve this Doc View Source

Open()

This method opens the text file for reading and writing. If file is already open, nothing will happen.

Declaration
public override bool Open()
Returns
Type Description
System.Boolean
true
if the text file successfully opens.
Overrides
TextFile.Open()
| Improve this Doc View Source

ReadLine()

This method reads a line of characters in the file and returns the data as a string.

Declaration
public override string ReadLine()
Returns
Type Description
System.String

A string from the text file.

Overrides
TextFile.ReadLine()
| Improve this Doc View Source

RestartReading()

This method resets the reader back to the beginning of the text file.

Declaration
public override void RestartReading()
Overrides
TextFile.RestartReading()
  • Improve this Doc
  • View Source
Back to top Generated by DocFX