/// <summary> /// Initializes a new instance of the <see cref="SourceControlDefinitionEditorViewModel" /> class. /// </summary> /// <param name="accessService">The TFS access service.</param> /// <param name="type">The resolver type.</param> /// <param name="xmlDependencyViewModel">The XML dependency view model.</param> /// <param name="validDependencyDefinitonFilenameList">The list with valid dependency definition filenames.</param> /// <param name="tpcUrl">The team project collection url.</param> internal SourceControlDefinitionEditorViewModel(ITfsAccessService accessService, IDependencyResolverType type, IXmlDependencyViewModel xmlDependencyViewModel, string validDependencyDefinitonFilenameList, string tpcUrl) { if (null == accessService) { throw new ArgumentNullException("accessService"); } if (type == null) { throw new ArgumentNullException("type"); } if (xmlDependencyViewModel == null) { throw new ArgumentNullException("xmlDependencyViewModel"); } if (xmlDependencyViewModel.XmlDependency == null) { throw new ArgumentException( "The argument xmlDependencyViewModel does not contain an IXmlDependency object.", "xmlDependencyViewModel"); } if (string.IsNullOrWhiteSpace(validDependencyDefinitonFilenameList)) { throw new ArgumentNullException("validDependencyDefinitonFilenameList"); } if (string.IsNullOrWhiteSpace(tpcUrl)) { throw new ArgumentNullException("tpcUrl"); } _tpcUrl = tpcUrl; _accessService = accessService; _accessService.Connect(new Uri(_tpcUrl)); _xmlDependencyViewModel = xmlDependencyViewModel; _xmlDependency = xmlDependencyViewModel.XmlDependency; _validDependencyDefinitonFilenameList = validDependencyDefinitonFilenameList; _validationErrors = new Dictionary <string, string>(); _versionSpecToDisplayStringDictionary = new Dictionary <string, string> { { "T", "Latest version" }, { "C", "Changeset" }, { "D", "Date" }, { "L", "Label" }, { "W", "Workspace Version" } }; _displayStringToVersionSpecDictionary = new Dictionary <string, string>(); foreach (var e in _versionSpecToDisplayStringDictionary) { _displayStringToVersionSpecDictionary.Add(e.Value, e.Key); } LoadAvailableVersionSpecs(); ValidateAll(); }
/// <summary> /// Validates the binary team project collection. /// </summary> /// <returns>True if binary team project collection is valid. Otherwise false.</returns> private bool ValidateBinaryTeamProjectCollection() { var value = SelectedBinaryTeamProjectCollection; string validationMessage = null; if (string.IsNullOrEmpty(value)) { validationMessage = "Binary repository team project collection url is required!"; } else if (!Uri.IsWellFormedUriString(value, UriKind.Absolute)) { validationMessage = "Binary repository team project collection url is invalid!"; } else { try { _accessService.Connect(new Uri(value)); } catch (Exception) { validationMessage = "Couldn't conntect to team project collection!"; } } if (validationMessage != null) { AddError("SelectedBinaryTeamProjectCollection", validationMessage); } else { RemoveError("SelectedBinaryTeamProjectCollection"); } return(validationMessage == null); }