///<summary> ///Try get a new <see cref="IEnvVarFilePath"/> object from this string. ///</summary> ///<returns><i>true</i> if <paramref name="pathString"/> is a valid file path prefixed with an environment variable and as a consequence, the returned <paramref name="envVarFilePath"/> is not null.</returns> ///<remarks> ///The path represented by this string doesn't need to exist for this operation to complete properly. ///The environment variable prefixing the path doesn't need to exist for this operation to complete properly. ///</remarks> ///<param name="pathString">Represents the path.</param> ///<param name="envVarFilePath">If this method returns <i>true</i>, this is the returned path object.</param> public static bool TryGetEnvVarFilePath(this string pathString, out IEnvVarFilePath envVarFilePath) { string failureReasonUnused; return pathString.TryGetEnvVarFilePath(out envVarFilePath, out failureReasonUnused); }
///<summary> ///Try get a new <see cref="IEnvVarFilePath"/> object from this string. ///</summary> ///<returns><i>true</i> if <paramref name="pathString"/> is a valid file path prefixed with an environment variable and as a consequence, the returned <paramref name="envVarFilePath"/> is not null.</returns> ///<remarks> ///The path represented by this string doesn't need to exist for this operation to complete properly. ///The environment variable prefixing the path doesn't need to exist for this operation to complete properly. ///</remarks> ///<param name="pathString">Represents the path.</param> ///<param name="envVarFilePath">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 TryGetEnvVarFilePath(this string pathString, out IEnvVarFilePath envVarFilePath, out string failureReason) { envVarFilePath = null; if (pathString.IsPathStringNullOrEmpty(out failureReason)) { return false; } if (!pathString.IsValidEnvVarFilePath(out failureReason)) { return false; } envVarFilePath = new EnvVarFilePath(pathString); return true; }