public FilePath(string path, IPathInteractor interactor, bool caseSensitive = false) { if (path == null) { throw new ArgumentNullException(nameof(path)); } if (interactor == null) { throw new ArgumentNullException(nameof(interactor)); } bool valid; try { valid = FilePath.InvariantCultureStringEquals(path, interactor.GetFullPath(path), caseSensitive) && interactor.IsPathRooted(path); } catch { // Using exceptions for control flow is bad practice, but such is life. valid = false; } if (!valid) { throw new ArgumentException(FilePath.InvalidPath, nameof(path)); } this.Path = path; this.CaseSensitive = caseSensitive; }
/// <summary> /// Instantiates a new <see cref="DirectoryInteractor"/> instance. /// </summary> /// <param name="pathInteractor"></param> public DirectoryInteractor(IPathInteractor pathInteractor) { this.pathInteractor = pathInteractor; }