VirtualStorageLibrary
Search Results for

    Show / Hide Table of Contents

    Class VirtualPath

    Represents a path within the virtual storage. Provides functionality for manipulating, comparing, normalizing, and splitting paths.

    Inheritance
    object
    VirtualPath
    Implements
    IEquatable<VirtualPath>
    IComparable<VirtualPath>
    IComparable
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: AkiraNetwork.VirtualStorageLibrary
    Assembly: VirtualStorageLibrary.dll
    Syntax
    public class VirtualPath : IEquatable<VirtualPath>, IComparable<VirtualPath>, IComparable

    Constructors

    VirtualPath(IEnumerable<VirtualNodeName>)

    Initializes a new instance of the VirtualPath class with the specified collection of path parts.

    Declaration
    public VirtualPath(IEnumerable<VirtualNodeName> parts)
    Parameters
    Type Name Description
    IEnumerable<VirtualNodeName> parts

    The collection of path parts.

    VirtualPath(string)

    Initializes a new instance of the VirtualPath class with the specified path string.

    Declaration
    public VirtualPath(string path)
    Parameters
    Type Name Description
    string path

    The initial path string.

    Properties

    Depth

    Gets the depth of the path.

    Declaration
    public int Depth { get; }
    Property Value
    Type Description
    int

    An integer representing the depth of the path.

    DirectoryPath

    Gets the directory part of the path.

    Declaration
    public VirtualPath DirectoryPath { get; }
    Property Value
    Type Description
    VirtualPath

    A VirtualPath representing the directory part of the path.

    Dot

    Gets the dot (".") symbol.

    Declaration
    public static string Dot { get; }
    Property Value
    Type Description
    string

    A string representing the dot symbol.

    DotDot

    Gets the double dot ("..") symbol.

    Declaration
    public static string DotDot { get; }
    Property Value
    Type Description
    string

    A string representing the double dot symbol.

    FixedDepth

    Gets the depth of the fixed path.

    Declaration
    public int FixedDepth { get; }
    Property Value
    Type Description
    int

    An integer representing the depth of the fixed path.

    Remarks

    The fixed depth indicates the number of parts in the path, excluding those with wildcards.

    FixedPath

    Gets the fixed path after applying wildcard matching.

    Declaration
    public VirtualPath FixedPath { get; }
    Property Value
    Type Description
    VirtualPath

    A VirtualPath object representing the fixed path.

    Remarks

    The fixed path excludes parts containing wildcards.

    IsAbsolute

    Gets a value indicating whether the instance's path is absolute.

    Declaration
    public bool IsAbsolute { get; }
    Property Value
    Type Description
    bool

    true if the instance's path is absolute; otherwise, false.

    IsDot

    Gets a value indicating whether the instance's path is a dot.

    Declaration
    public bool IsDot { get; }
    Property Value
    Type Description
    bool

    true if the instance's path is a dot; otherwise, false.

    IsDotDot

    Gets a value indicating whether the instance's path is a double dot.

    Declaration
    public bool IsDotDot { get; }
    Property Value
    Type Description
    bool

    true if the instance's path is a double dot; otherwise, false.

    IsEmpty

    Gets a value indicating whether the instance's path is empty.

    Declaration
    public bool IsEmpty { get; }
    Property Value
    Type Description
    bool

    true if the instance's path is empty; otherwise, false.

    IsEndsWithSlash

    Gets a value indicating whether the instance's path ends with a slash.

    Declaration
    public bool IsEndsWithSlash { get; }
    Property Value
    Type Description
    bool

    true if the instance's path ends with a slash; otherwise, false.

    IsRoot

    Gets a value indicating whether the instance's path is the root path.

    Declaration
    public bool IsRoot { get; }
    Property Value
    Type Description
    bool

    true if the instance's path is the root path; otherwise, false.

    NodeName

    Gets the node name of the path.

    Declaration
    public VirtualNodeName NodeName { get; }
    Property Value
    Type Description
    VirtualNodeName

    A VirtualNodeName representing the node name of the path.

    PartsList

    Gets the list of parts that make up the path.

    Declaration
    public List<VirtualNodeName> PartsList { get; }
    Property Value
    Type Description
    List<VirtualNodeName>

    A list of VirtualNodeName objects representing the parts of the path.

    Path

    Gets the path string.

    Declaration
    public string Path { get; }
    Property Value
    Type Description
    string

    The string representation of the path.

    Root

    Gets the root path.

    Declaration
    public static string Root { get; }
    Property Value
    Type Description
    string

    A string representing the root path.

    Separator

    Gets the path separator character.

    Declaration
    public static char Separator { get; }
    Property Value
    Type Description
    char

    A character representing the path separator.

    Methods

    AddEndSlash()

    Adds a trailing slash to the path if it doesn't already have one.

    Declaration
    public VirtualPath AddEndSlash()
    Returns
    Type Description
    VirtualPath

    A new VirtualPath with a trailing slash.

    AddStartSlash()

    Adds a leading slash to the path if it doesn't already have one.

    Declaration
    public VirtualPath AddStartSlash()
    Returns
    Type Description
    VirtualPath

    A new VirtualPath with a leading slash.

    ArePathsSubdirectories(VirtualPath, VirtualPath)

    Determines whether one path is a subdirectory of another path.

    Declaration
    public static bool ArePathsSubdirectories(VirtualPath path1, VirtualPath path2)
    Parameters
    Type Name Description
    VirtualPath path1

    The first VirtualPath.

    VirtualPath path2

    The second VirtualPath.

    Returns
    Type Description
    bool

    true if one path is a subdirectory of the other; otherwise, false.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if either path is empty.

    Combine(params VirtualPath[])

    Combines the instance's path with the specified paths.

    Declaration
    public VirtualPath Combine(params VirtualPath[] paths)
    Parameters
    Type Name Description
    VirtualPath[] paths

    An array of VirtualPath objects to combine.

    Returns
    Type Description
    VirtualPath

    A new VirtualPath representing the combined path.

    Combine(params string[])

    Combines the specified paths into a single path.

    Declaration
    public static string Combine(params string[] paths)
    Parameters
    Type Name Description
    string[] paths

    An array of path strings to combine.

    Returns
    Type Description
    string

    A combined path string.

    CombineFromIndex(VirtualPath, int)

    Combines the instance's path with the parts of another path starting from a specified index.

    Declaration
    public VirtualPath CombineFromIndex(VirtualPath path, int index)
    Parameters
    Type Name Description
    VirtualPath path

    The VirtualPath whose parts to combine.

    int index

    The starting index from which to combine the parts.

    Returns
    Type Description
    VirtualPath

    A new VirtualPath representing the combined path.

    CompareTo(VirtualPath?)

    Compares the instance's path with another VirtualPath.

    Declaration
    public int CompareTo(VirtualPath? other)
    Parameters
    Type Name Description
    VirtualPath other

    The other VirtualPath to compare with.

    Returns
    Type Description
    int

    An integer indicating the relative order of the paths.

    CompareTo(object?)

    Compares the instance's path with another object.

    Declaration
    public int CompareTo(object? other)
    Parameters
    Type Name Description
    object other

    The object to compare with.

    Returns
    Type Description
    int

    An integer indicating the relative order of the paths.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the object is not a VirtualPath.

    Equals(VirtualPath?)

    Indicates whether this path is equal to the specified VirtualPath object.

    Declaration
    public bool Equals(VirtualPath? other)
    Parameters
    Type Name Description
    VirtualPath other

    The VirtualPath object to compare with the instance's path.

    Returns
    Type Description
    bool

    true if the specified VirtualPath is equal to the instance's path; otherwise, false.

    Equals(object?)

    Indicates whether this path is equal to the specified object.

    Declaration
    public override bool Equals(object? obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with the instance's path.

    Returns
    Type Description
    bool

    true if the specified object is equal to the instance's path; otherwise, false.

    Overrides
    object.Equals(object)

    GetHashCode()

    Returns the hash code for this path.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    The hash code for this path.

    Overrides
    object.GetHashCode()

    GetNodeName()

    Retrieves the node name from the instance's path.

    Declaration
    public VirtualNodeName GetNodeName()
    Returns
    Type Description
    VirtualNodeName

    A VirtualNodeName object representing the node name.

    GetParentPath()

    Gets the parent path of the instance's path.

    Declaration
    public VirtualPath GetParentPath()
    Returns
    Type Description
    VirtualPath

    A VirtualPath representing the parent path.

    GetPartsLinkedList()

    Gets the parts of the path as a linked list.

    Declaration
    public LinkedList<VirtualNodeName> GetPartsLinkedList()
    Returns
    Type Description
    LinkedList<VirtualNodeName>

    A LinkedList<T> of VirtualNodeName objects representing the path parts.

    GetPartsList()

    Retrieves the node parts of the path as a list. This method converts the node parts stored in a linked list structure into a list structure, making it more convenient for sequential access and operations that require indexing.

    Declaration
    public List<VirtualNodeName> GetPartsList()
    Returns
    Type Description
    List<VirtualNodeName>

    A List<T> of VirtualNodeName objects representing the node parts of the path.

    GetRelativePath(VirtualPath)

    Gets the relative path from the specified base path.

    Declaration
    public VirtualPath GetRelativePath(VirtualPath basePath)
    Parameters
    Type Name Description
    VirtualPath basePath

    The base path.

    Returns
    Type Description
    VirtualPath

    A VirtualPath representing the relative path.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if the instance's path is not absolute: This exception occurs when the method is called on a VirtualPath instance that does not start with the root path separator, indicating that it is not an absolute path. Thrown if the base path is not absolute: This exception occurs when the basePath argument does not start with the root path separator, indicating that it is not an absolute path. Both the instance's path and the base path must be absolute paths to compute a relative path.

    IsSubdirectory(VirtualPath)

    Determines whether this instance's path is a subdirectory of the specified parent path.

    Declaration
    public bool IsSubdirectory(VirtualPath parentPath)
    Parameters
    Type Name Description
    VirtualPath parentPath

    The parent VirtualPath.

    Returns
    Type Description
    bool

    true if this instance's path is a subdirectory of the parent path; otherwise, false.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if this instance's path or the parent path is empty.

    IsValidPath(VirtualPath)

    Checks if all node names in the specified VirtualPath are considered valid by IsValidNodeName(VirtualNodeName). Returns false immediately if an invalid node name is found.

    Declaration
    public static bool IsValidPath(VirtualPath path)
    Parameters
    Type Name Description
    VirtualPath path

    The VirtualPath object to validate.

    Returns
    Type Description
    bool

    true if all node names are valid; otherwise, false if any invalid node name is found.

    NormalizePath()

    Normalizes the instance's path.

    Declaration
    public VirtualPath NormalizePath()
    Returns
    Type Description
    VirtualPath

    A new VirtualPath instance with the normalized path.

    NormalizePath(string)

    Normalizes the specified path string.

    Declaration
    public static string NormalizePath(string path)
    Parameters
    Type Name Description
    string path

    The path string to normalize.

    Returns
    Type Description
    string

    A normalized path string.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when attempting to navigate above the root directory.

    StartsWith(VirtualPath)

    Determines whether the instance's path starts with the specified path.

    Declaration
    public bool StartsWith(VirtualPath path)
    Parameters
    Type Name Description
    VirtualPath path

    The VirtualPath to compare with.

    Returns
    Type Description
    bool

    true if the instance's path starts with the specified path; otherwise, false.

    ToString()

    Returns a string that represents the instance's path.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that represents the instance's path.

    Overrides
    object.ToString()

    TrimEndSlash()

    Removes the trailing slash from the path.

    Declaration
    public VirtualPath TrimEndSlash()
    Returns
    Type Description
    VirtualPath

    A new VirtualPath without the trailing slash.

    Operators

    operator +(VirtualPath, VirtualNodeName)

    Combines a VirtualPath with a VirtualNodeName.

    Declaration
    public static VirtualPath operator +(VirtualPath path, VirtualNodeName nodeName)
    Parameters
    Type Name Description
    VirtualPath path

    The VirtualPath.

    VirtualNodeName nodeName

    The VirtualNodeName.

    Returns
    Type Description
    VirtualPath

    A new VirtualPath representing the combined path.

    operator +(VirtualPath, VirtualPath)

    Combines two VirtualPath instances.

    Declaration
    public static VirtualPath operator +(VirtualPath path1, VirtualPath path2)
    Parameters
    Type Name Description
    VirtualPath path1

    The first VirtualPath.

    VirtualPath path2

    The second VirtualPath.

    Returns
    Type Description
    VirtualPath

    A new VirtualPath representing the combined path.

    operator +(VirtualPath, char)

    Combines a VirtualPath with a character.

    Declaration
    public static VirtualPath operator +(VirtualPath path, char chr)
    Parameters
    Type Name Description
    VirtualPath path

    The VirtualPath.

    char chr

    The character to combine with the path.

    Returns
    Type Description
    VirtualPath

    A new VirtualPath representing the combined path.

    operator +(VirtualPath, string)

    Combines a VirtualPath with a string.

    Declaration
    public static VirtualPath operator +(VirtualPath path, string str)
    Parameters
    Type Name Description
    VirtualPath path

    The VirtualPath.

    string str

    The string to combine with the path.

    Returns
    Type Description
    VirtualPath

    A new VirtualPath representing the combined path.

    operator +(char, VirtualPath)

    Combines a character with a VirtualPath.

    Declaration
    public static VirtualPath operator +(char chr, VirtualPath path)
    Parameters
    Type Name Description
    char chr

    The character to combine with the path.

    VirtualPath path

    The VirtualPath.

    Returns
    Type Description
    VirtualPath

    A new VirtualPath representing the combined path.

    operator +(string, VirtualPath)

    Combines a string with a VirtualPath.

    Declaration
    public static VirtualPath operator +(string str, VirtualPath path)
    Parameters
    Type Name Description
    string str

    The string to combine with the path.

    VirtualPath path

    The VirtualPath.

    Returns
    Type Description
    VirtualPath

    A new VirtualPath representing the combined path.

    operator ==(VirtualPath?, VirtualPath?)

    Determines whether two VirtualPath instances are equal.

    Declaration
    public static bool operator ==(VirtualPath? left, VirtualPath? right)
    Parameters
    Type Name Description
    VirtualPath left

    The left VirtualPath.

    VirtualPath right

    The right VirtualPath.

    Returns
    Type Description
    bool

    true if the paths are equal; otherwise, false.

    implicit operator string(VirtualPath?)

    Implicitly converts a VirtualPath to a string.

    Declaration
    public static implicit operator string(VirtualPath? virtualPath)
    Parameters
    Type Name Description
    VirtualPath virtualPath

    The VirtualPath object.

    Returns
    Type Description
    string

    The string representation of the VirtualPath, or an empty string if the path is null.

    implicit operator VirtualPath(string)

    Implicitly converts a string to a VirtualPath.

    Declaration
    public static implicit operator VirtualPath(string path)
    Parameters
    Type Name Description
    string path

    The string representation of the path.

    Returns
    Type Description
    VirtualPath

    A VirtualPath object representing the given string path.

    operator !=(VirtualPath?, VirtualPath?)

    Determines whether two VirtualPath instances are not equal.

    Declaration
    public static bool operator !=(VirtualPath? left, VirtualPath? right)
    Parameters
    Type Name Description
    VirtualPath left

    The left VirtualPath.

    VirtualPath right

    The right VirtualPath.

    Returns
    Type Description
    bool

    true if the paths are not equal; otherwise, false.

    Implements

    IEquatable<T>
    IComparable<T>
    IComparable

    Extension Methods

    VirtualTextFormatter.GenerateSingleTableDebugText<T>(T)
    In this article
    Back to top Generated by DocFX