Ejemplo n.º 1
0
        /// <summary>
        /// Posts the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <exception cref="ResourceNotFoundException"></exception>
        public void Post(InstallPackage request)
        {
            var package = string.IsNullOrEmpty(request.Version) ?
                          _installationManager.GetLatestCompatibleVersion(request.Name, request.AssemblyGuid, _appHost.ApplicationVersion, request.UpdateClass).Result :
                          _installationManager.GetPackage(request.Name, request.AssemblyGuid, request.UpdateClass, Version.Parse(request.Version)).Result;

            if (package == null)
            {
                throw new ResourceNotFoundException(string.Format("Package not found: {0}", request.Name));
            }

            Task.Run(() => _installationManager.InstallPackage(package, new Progress <double>(), CancellationToken.None));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Posts the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <exception cref="ResourceNotFoundException"></exception>
        public async Task Post(InstallPackage request)
        {
            var package = string.IsNullOrEmpty(request.Version) ?
                          await _installationManager.GetLatestCompatibleVersion(request.Name, request.AssemblyGuid, typeof(PackageService).Assembly.GetName().Version, request.UpdateClass).ConfigureAwait(false) :
                          await _installationManager.GetPackage(request.Name, request.AssemblyGuid, request.UpdateClass, Version.Parse(request.Version)).ConfigureAwait(false);

            if (package == null)
            {
                throw new ResourceNotFoundException(string.Format("Package not found: {0}", request.Name));
            }

            await _installationManager.InstallPackage(package, new SimpleProgress <double>(), CancellationToken.None);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Posts the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <exception cref="ResourceNotFoundException"></exception>
        public async Task Post(InstallPackage request)
        {
            var packages = await _installationManager.GetAvailablePackages().ConfigureAwait(false);

            var package = _installationManager.GetCompatibleVersions(
                packages,
                request.Name,
                string.IsNullOrEmpty(request.AssemblyGuid) ? Guid.Empty : Guid.Parse(request.AssemblyGuid),
                string.IsNullOrEmpty(request.Version) ? null : Version.Parse(request.Version)).FirstOrDefault();

            if (package == null)
            {
                throw new ResourceNotFoundException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              "Package not found: {0}",
                              request.Name));
            }

            await _installationManager.InstallPackage(package);
        }