///<summary> ///Try get a new <see cref="IVariableDirectoryPath"/> object from this string. ///</summary> ///<returns><i>true</i> if <paramref name="pathString"/> is a valid directory path that contains variables and as a consequence, the returned <paramref name="variableDirectoryPath"/> is not null.</returns> ///<remarks>The path represented by this string doesn't need to exist for this operation to complete properly.</remarks> ///<param name="pathString">Represents the path.</param> ///<param name="variableDirectoryPath">If this method returns <i>true</i>, this is the returned path object.</param> ///<param name="failureReason">If this method returns <i>false</i>, this is the plain english description of the failure.</param> public static bool TryGetVariableDirectoryPath(this string pathString, out IVariableDirectoryPath variableDirectoryPath, out string failureReason) { variableDirectoryPath = null; if (pathString.IsPathStringNullOrEmpty(out failureReason)) { return false; } if (!pathString.IsValidVariableDirectoryPath(out failureReason)) { return false; } variableDirectoryPath = new VariableDirectoryPath(pathString); return true; }
/// <summary> /// Try get a new <see cref="IVariableDirectoryPath" /> object from this string. /// </summary> /// <returns> /// <i>true</i> if <paramref name="path" /> is a valid directory path that contains variables and as a consequence, the returned /// <paramref name="directoryPath" /> is not null. /// </returns> /// <remarks>The path represented by this string doesn't need to exist for this operation to complete properly.</remarks> /// <param name="path">Represents the path.</param> /// <param name="directoryPath">If this method returns <i>true</i>, this is the returned path object.</param> /// <param name="failureMessage">If this method returns <i>false</i>, this is the plain english description of the failure.</param> public static bool TryGetVariableDirectoryPath(this string path, out IVariableDirectoryPath directoryPath, out string failureMessage) { directoryPath = null; if (IsNullOrEmpty(() => path, out failureMessage)) { return false; } if (!path.IsValidVariableDirectoryPath(out failureMessage)) { return false; } directoryPath = new VariableDirectoryPath(path); return true; }