/// <summary> /// Initializes a new instance of the <see cref="VirtualPath"/> class. /// </summary> /// <param name="elements">Path element array.</param> /// <param name="type">Type of the path.</param> /// <param name="drive">Drive letter of an absolute path.</param> private VirtualPath(string[] elements, VirtualPathType type, DriveLetter?drive) : this() { this.pathElements = elements.Length > 0 ? elements : Array.Empty <string>(); this.pathType = type; this.driveLetter = drive; }
public void CanGetRootPath(string path, VirtualPathType expectedType) { var vPath = new VirtualPath(path); CollectionAssert.IsEmpty(vPath.Parts); Assert.AreEqual(expectedType, vPath.Type); }
public void CanDetectPathType(string path, VirtualPathType type, string expectedPath) { var vpath = new VirtualPath(path); Assert.AreEqual(type, vpath.Type); Assert.AreEqual(expectedPath, vpath.Path); }
/// <summary> /// Initializes a new instance of the <see cref="VirtualPath"/> class. /// </summary> public VirtualPath() { this.pathElements = Array.Empty <string>(); this.pathType = VirtualPathType.Relative; this.cachedPath = new Lazy <string>(() => string.Join("\\", this.pathElements), true); this.cachedFullPath = new Lazy <string>(this.BuildFullPath, true); }
public ZipVirtualPathCollection (String virtualPath, VirtualPathType requestType, ZipFile zipFile) { _paths = new ArrayList(); _virtualPath = virtualPath; _requestType = requestType; _zipFile = zipFile; PerformEnumeration (); }
public void CanAppend(string first, string second, VirtualPathType expectedType, string expectedPath) { var v1 = new VirtualPath(first); var v2 = new VirtualPath(second); var actual = v1.Append(v2); Assert.AreEqual(expectedType, actual.Type); Assert.AreEqual(expectedPath, actual.Path); }
public ZipVirtualPathCollection(String virtualPath, VirtualPathType requestType, ZipFile zipFile) { _paths = new ArrayList(); _virtualPath = virtualPath; _requestType = requestType; _zipFile = zipFile; PerformEnumeration(); }
private VirtualPath GetSubPathInternal(VirtualPath other, bool ignoreCase, VirtualPathType type) { if (this.Parts.Count > other.Parts.Count) { return(null); } var comparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; for (var i = 0; i < this.Parts.Count; i++) { if (!this.Parts[i].Equals(other.Parts[i], comparison)) { return(null); } } return(new VirtualPath(other.Parts.Skip(this.Parts.Count), type)); }
/// <summary> /// Initializes a new instance of the <see cref="VirtualPath"/> class. /// </summary> /// <param name="path">String representation of an absolute or relative path.</param> public VirtualPath(string path) : this() { if (path == null) { throw new ArgumentNullException(nameof(path)); } var instance = Parse(path, out var error); if (instance == null) { throw error; } this.driveLetter = instance.driveLetter; this.pathElements = instance.pathElements; this.pathType = instance.pathType; }
/// <summary> /// Creates a new instance of the <see cref="VirtualPath"/> class, /// from the constituent parts of the path and its type. /// </summary> /// <param name="parts"></param> /// <param name="type"></param> public VirtualPath(IEnumerable<string> parts, VirtualPathType type) { Type = type; Parts = GetParts(parts).ToList().AsReadOnly(); Path = String.Join("/", Parts); }
private VirtualPath GetSubPathInternal(VirtualPath other, bool ignoreCase, VirtualPathType type) { if (this.Parts.Count > other.Parts.Count) return null; var comparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; for (var i = 0; i < this.Parts.Count; i++) { if (!this.Parts[i].Equals(other.Parts[i], comparison)) return null; } return new VirtualPath(other.Parts.Skip(this.Parts.Count), type); }
/// <summary> /// Creates a new instance of the <see cref="VirtualPath"/> class, /// from the constituent parts of the path and its type. /// </summary> /// <param name="parts"></param> /// <param name="type"></param> public VirtualPath(IEnumerable <string> parts, VirtualPathType type) { Type = type; Parts = GetParts(parts).ToList().AsReadOnly(); Path = String.Join("/", Parts); }