///<summary> ///Try get a new <see cref="IVariableFilePath"/> object from this string. ///</summary> ///<returns><i>true</i> if <paramref name="pathString"/> is a valid file path that contains variables and as a consequence, the returned <paramref name="variableFilePath"/> 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="variableFilePath">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 TryGetVariableFilePath(this string pathString, out IVariableFilePath variableFilePath, out string failureReason) { variableFilePath = null; if (pathString.IsPathStringNullOrEmpty(out failureReason)) { return false; } if (!pathString.IsValidVariableFilePath(out failureReason)) { return false; } variableFilePath = new VariableFilePath(pathString); return true; }
/// <summary> /// Try get a new <see cref="IVariableFilePath" /> object from this string. /// </summary> /// <returns> /// <i>true</i> if <paramref name="path" /> is a valid file path that contains variables and as a consequence, the returned /// <paramref name="filePath" /> 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="filePath">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 TryGetVariableFilePath(this string path, out IVariableFilePath filePath, out string failureMessage) { filePath = null; if (IsNullOrEmpty(() => path, out failureMessage)) { return false; } if (!path.IsValidVariableFilePath(out failureMessage)) { return false; } filePath = new VariableFilePath(path); return true; }