public async void AddSource() { if (string.IsNullOrWhiteSpace(NewSourceName)) { _progressService.ShowMessageAsync("New Source", "Source must have a name."); return; } if (Sources.Any(s => String.Compare(s.Name, NewSourceName, StringComparison.InvariantCultureIgnoreCase) == 0)) { _progressService.ShowMessageAsync("New Source", "There's already a source with that name."); return; } if (string.IsNullOrWhiteSpace(NewSourceUrl)) { _progressService.ShowMessageAsync("New Source", "Source must have a Url."); return; } if (Sources.Any(s => String.Compare(s.Url, NewSourceUrl, StringComparison.InvariantCultureIgnoreCase) == 0)) { _progressService.ShowMessageAsync("New Source", "There's already a source with that url."); return; } Uri url; if (!Uri.TryCreate(NewSourceUrl, UriKind.Absolute, out url)) { _progressService.ShowMessageAsync("New Source", "Source url is malformed."); return; } if (!(await _packageService.Value.TestSourceUrl(url))) { _progressService.ShowMessageAsync("New Source", "Failed to query source."); return; } _sourceService.AddSource(new SourceViewModel { Name = NewSourceName, Url = NewSourceUrl }); NewSourceName = ""; NewSourceUrl = ""; }