/// <summary> /// Validates that a supplied URI has a value and the proper format and scheme. /// </summary> /// <param name="argumentValue">Value of the argument</param> /// <param name="argumentName">Name of the argument</param> /// <param name="uriType">Type of Uri to validate</param> /// <exception cref="System.ArgumentException"/> /// <exception cref="System.ArgumentNullException"/> public static void ValidateTfsUri(System.Uri argumentValue, string argumentName, TfsUriType uriType) { ValidateObjectIsNotNull(argumentValue, argumentName); try { bool throwException = false; string exceptionMessage = string.Empty; switch (uriType) { case TfsUriType.ProjectCollection: if (argumentValue.Scheme.Equals("http", StringComparison.OrdinalIgnoreCase) || argumentValue.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) { throwException = true; exceptionMessage = "Project collection Uri scheme is not valid."; } if (argumentValue.Segments.Length != 1) { throwException = true; exceptionMessage = "Project collection Uri requires a project collection to be specified."; } break; case TfsUriType.BuildServer: break; case TfsUriType.Build: break; case TfsUriType.BuildDefinition: break; case TfsUriType.Service: break; default: break; } if (throwException) { throw new ArgumentException(exceptionMessage, argumentName); } } catch (Exception ex) { throw new ArgumentException("Uri is invalid", argumentName, ex); } }