Exemplo n.º 1
0
        public PackageControl(IPackageControlViewModel viewModel, IPackageViewModel packageViewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }

            InitializeComponent();
            viewModel.Package = packageViewModel;
            DataContext = viewModel;
        }
Exemplo n.º 2
0
        public async void UpdatePackageLists(string id, Uri source, IPackageViewModel newPackage, SemanticVersion version)
        {
            if (newPackage != null)
            {
                this.AddPackageEntry(newPackage.Id, newPackage.Version, source);
            }

            this.NotifyPackagesChanged(PackagesChangedEventType.Installed, id, version == null ? string.Empty : version.ToString());

            await this.ProgressService.StopLoading();
        }
Exemplo n.º 3
0
        public PackageControl(IPackageControlViewModel viewModel, IPackageViewModel packageViewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }

            InitializeComponent();
            viewModel.Package = packageViewModel;
            DataContext       = viewModel;
        }
Exemplo n.º 4
0
        public static async Task<IPackageViewModel> EnsureIsLoaded(IPackageViewModel viewModel, Uri source)
        {
            var service = GetFeed(source);

            var feedQuery =
                    (DataServiceQuery<V2FeedPackage>)service.Packages.Where(package => package.Id == viewModel.Id && package.Version == viewModel.Version.ToString());
            var result = await Task.Factory.FromAsync(feedQuery.BeginExecute, ar => feedQuery.EndExecute(ar), null);
            var v2FeedPackages = result as IList<V2FeedPackage> ?? result.ToList();

            if (result == null || !v2FeedPackages.Any())
            {
                return null;
            }

            var packageInfo = v2FeedPackages.Single();
            return AutoMapper.Mapper.Map(packageInfo, viewModel);
        }
Exemplo n.º 5
0
        public static async Task <IPackageViewModel> EnsureIsLoaded(IPackageViewModel vm, Uri source)
        {
            var service = GetFeed(source);

            var feedQuery =
                (DataServiceQuery <V2FeedPackage>)service.Packages.Where(package => package.Id == vm.Id && package.Version == vm.Version.ToString());
            var result = await Task.Factory.FromAsync(feedQuery.BeginExecute, ar => feedQuery.EndExecute(ar), null);

            var v2FeedPackages = result as IList <V2FeedPackage> ?? result.ToList();

            if (result == null || !v2FeedPackages.Any())
            {
                return(null);
            }

            var packageInfo = v2FeedPackages.Single();

            return(AutoMapper.Mapper.Map(packageInfo, vm));
        }
Exemplo n.º 6
0
        public void PopulatePackages(IPackageViewModel packageInfo, ICollection <IPackageViewModel> packages)
        {
            if (packages == null)
            {
                throw new ArgumentNullException("packages");
            }

            var packageConfigEntry =
                this.PackageConfigEntries()
                .FirstOrDefault(
                    entry =>
                    string.Compare(entry.Id, packageInfo.Id, StringComparison.OrdinalIgnoreCase) == 0 &&
                    entry.Version == packageInfo.Version);

            if (packageConfigEntry != null)
            {
                packageInfo.Source = packageConfigEntry.Source;
            }

            packages.Add(packageInfo);
        }
Exemplo n.º 7
0
        public async void UpdatePackageLists(string id, Uri source, IPackageViewModel newPackage, SemanticVersion version)
        {
            if (newPackage != null)
            {
                this.AddPackageEntry(newPackage.Id, newPackage.Version, source);
            }

            this.NotifyPackagesChanged(PackagesChangedEventType.Installed, id, version == null ? string.Empty : version.ToString());

            await this.ProgressService.StopLoading();
        }
Exemplo n.º 8
0
        public void PopulatePackages(IPackageViewModel packageInfo, ICollection<IPackageViewModel> packages)
        {
            if (packages == null)
            {
                throw new ArgumentNullException("packages");
            }

            var packageConfigEntry =
                this.PackageConfigEntries()
                    .FirstOrDefault(
                        entry =>
                        string.Compare(entry.Id, packageInfo.Id, StringComparison.OrdinalIgnoreCase) == 0
                        && entry.Version == packageInfo.Version);

            if (packageConfigEntry != null)
            {
                packageInfo.Source = packageConfigEntry.Source;
            }

            packages.Add(packageInfo);
        }
 public ShowPackageDetailsMessage(IPackageViewModel package)
 {
     Package = package;
 }
Exemplo n.º 10
0
 public PackageChangedMessage(IPackageViewModel package, PackageChangeType changeType, SemanticVersion version = null)
 {
     Package    = package;
     ChangeType = changeType;
     Version    = version;
 }
Exemplo n.º 11
0
 public static Task <IPackageViewModel> EnsureIsLoaded(IPackageViewModel viewModel)
 {
     return(Task.Run(() => viewModel));
 }
 public static Task <IPackageViewModel> EnsureIsLoaded(IPackageViewModel vm, Uri source)
 {
     return(TaskEx.Run(() => vm));
 }
Exemplo n.º 13
0
        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 static Task<IPackageViewModel> EnsureIsLoaded(IPackageViewModel viewModel)
 {
     return Task.Run(() => viewModel);
 }
Exemplo n.º 15
0
 public PackageControl(IPackageControlViewModel vm, IPackageViewModel packageViewModel)
 {
     InitializeComponent();
     vm.Package  = packageViewModel;
     DataContext = vm;
 }
Exemplo n.º 16
0
        public async Task<IPackageViewModel> EnsureIsLoaded(IPackageViewModel viewModel, Uri source = null)
        {
            await this._progressService.StartLoading("Loading Package Information");
            this._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 = this._sourceService.GetDefaultSource();
                var defaultSource = new Uri(defaultSourceVm.Url);
                if (defaultSource.Scheme == "http" || defaultSource.Scheme == "https")
                {
                    var result = await ODataPackageService.EnsureIsLoaded(viewModel, defaultSource);
                    if (result != null)
                    {
                        await this._progressService.StopLoading();
                        result.Source = defaultSource;
                        return result;
                    }
                }

                foreach (var sourceViewModel in this._sourceService.GetSources())
                {
                    var currentSource = new Uri(sourceViewModel.Url);
                    if (currentSource.Scheme == "http" || currentSource.Scheme == "https")
                    {
                        var result = await ODataPackageService.EnsureIsLoaded(viewModel, currentSource);
                        if (result == null)
                        {
                            continue;
                        }

                        await this._progressService.StopLoading();
                        result.Source = currentSource;
                        return result;
                    }
                }
            }
            else
            {
                if (source.Scheme == "http" || source.Scheme == "https")
                {
                    var result = await ODataPackageService.EnsureIsLoaded(viewModel, source);
                    await this._progressService.StopLoading();
                    if (result != null)
                    {
                        result.Source = source;
                    }

                    return result;
                }

                if (source.IsFile || source.IsUnc)
                {
                    await this._progressService.StopLoading();
                    return null;
                }
            }

            await this._progressService.StopLoading();
            return null;
        }