public async Task <PackageSearchResults> Search(string query, PackageSearchOptions options, Uri source = null) { await this._progressService.StartLoading("Search"); if (string.IsNullOrWhiteSpace(query)) { this._progressService.WriteMessage("Loading data..."); } else { this._progressService.WriteMessage(string.Format("Searching for {0}", query)); } if (source == null) { source = new Uri(this._sourceService.GetDefaultSource().Url); } if (source.Scheme == "http" || source.Scheme == "https") { var results = await ODataPackageService.Search(query, this._packageFactory, options, source); await this._progressService.StopLoading(); return(results); } if (source.IsFile || source.IsUnc) { await this._progressService.StopLoading(); return(null); } throw new InvalidDataException("Invalid Source Uri. Double check that you current source is a valid endpoint."); }
public async Task <IPackageViewModel> EnsureIsLoaded(IPackageViewModel vm, Uri source = null) { await _progressService.StartLoading("Loading Package Information"); _progressService.WriteMessage("Loading remote package information..."); // If we don't have a source, iterate through our source until we find one that matches. if (source == null) { var defaultSourceVm = _sourceService.GetDefaultSource(); var defaultSource = new Uri(defaultSourceVm.Url); if (defaultSource.Scheme == "http" || defaultSource.Scheme == "https") { var result = await ODataPackageService.EnsureIsLoaded(vm, defaultSource); if (result != null) { await _progressService.StopLoading(); result.Source = defaultSource; return(result); } } foreach (var sourceViewModel in _sourceService.GetSources()) { var currentSource = new Uri(sourceViewModel.Url); if (currentSource.Scheme == "http" || currentSource.Scheme == "https") { var result = await ODataPackageService.EnsureIsLoaded(vm, currentSource); if (result == null) { continue; } await _progressService.StopLoading(); result.Source = currentSource; return(result); } } } else { if (source.Scheme == "http" || source.Scheme == "https") { var result = await ODataPackageService.EnsureIsLoaded(vm, source); await _progressService.StopLoading(); if (result != null) { result.Source = source; } return(result); } if (source.IsFile || source.IsUnc) { await _progressService.StopLoading(); return(null); } } await _progressService.StopLoading(); return(null); }
public PackageContext(ODataPackageService oDataPackageService) { this.oDataPackageService = oDataPackageService; }