Class FileLineIndex
Represents a location in a file by its file index and line number.
public class FileLineIndex : IFileLineIndex, IGetFileLineIndex, IComparable<IFileLineIndex>, IMakeXmlSource, IToXElement
- Inheritance
-
FileLineIndex
- Implements
- Inherited Members
- Extension Methods
Constructors
FileLineIndex()
Initializes a new instance of the FileLineIndex class.
public FileLineIndex()
FileLineIndex(IFileLineIndex)
Initializes a new instance of the FileLineIndex class by copying another instance.
public FileLineIndex(IFileLineIndex src)
Parameters
src
IFileLineIndexThe source FileLineIndex to copy from
FileLineIndex(int, int)
Initializes a new instance of the FileLineIndex class with specified indices.
public FileLineIndex(int fileIndex, int lineIndex)
Parameters
FileLineIndex(XElement)
Initializes a new instance of the FileLineIndex class from an XML element.
public FileLineIndex(XElement src)
Parameters
src
XElementThe XML element containing the file and line indices
Properties
FileIndex
File Index. Start on 0.
public int FileIndex { get; set; }
Property Value
FileNo
Gets or sets the one-based file number (FileIndex + 1)
public int FileNo { get; set; }
Property Value
LineIndex
Line Index. Start on 0.
public int LineIndex { get; set; }
Property Value
LineNo
Gets or sets the one-based line number (LineIndex + 1)
public int LineNo { get; set; }
Property Value
XName
Gets the XML element name used for serialization.
public static string XName { get; }
Property Value
Methods
CompareTo(IFileLineIndex)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(IFileLineIndex other)
Parameters
other
IFileLineIndexAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes other
in the sort order.Zero This instance occurs in the same position in the sort order as other
.Greater than zero This instance follows other
in the sort order.
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
GetFileLineIndex()
Get FileLineIndex.
public FileLineIndex GetFileLineIndex()
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
MakeXmlSource(string, string, bool)
Creates an XML representation of the object. This method may also generate additional resources such as related files.
public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)
Parameters
baseDirectory
stringThe base directory for resolving relative paths
relFile
stringThe relative file path for the XML source
exhibitionOnly
boolif true, the extended file creation is suppressed.
Returns
- XElement
An XML element representing the object's state
Remarks
For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied.
The baseDirectory
is typically the folder at the nearest configuration file folder.
Since the folder can be moving with the configuration file.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToUserString()
Returns a user-friendly string representation of the file and line numbers.
public string ToUserString()
Returns
- string
A string in the format “(FileNo:X,LineNo:Y)”
ToXElement()
Get the XElement to represent the object.
public XElement ToXElement()