public PackageControlButtonEventArgs(PackageMetadata package, PackageControlButton button)
        {
            if (package == null)
                throw new ArgumentNullException("package");

            Package = package;
            Button = button;
        }
Exemple #2
0
        public SetupPackage(PackageMetadata metadata, bool isInConfiguration, string installedVersion)
        {
            if (metadata == null)
                throw new ArgumentNullException("metadata");

            Metadata = metadata;
            IsInConfiguration = isInConfiguration;
            InstalledVersion = installedVersion;
        }
Exemple #3
0
        public PackageControl(PackageMetadata package, PackageCategory category)
        {
            if (package == null)
                throw new ArgumentNullException("package");

            SetStyle(ControlStyles.Selectable | ControlStyles.ResizeRedraw, true);
            TabStop = false;

            Package = package;

            InitializeComponent();

            _icon.Image =
            _icon.ErrorImage =
            _icon.InitialImage =
                NeutralResources.NuGetPackage;

            HookMouseEvents(this);

            if (!String.IsNullOrEmpty(package.IconUrl))
                PackageImageCache.LoadImage(package.IconUrl, _icon);

            _title.Text = Normalize(package.Title);
            _description.Text = Normalize(package.Description);

            bool isCorePackage = package.State.HasFlag(PackageState.CorePackage);

            switch (category)
            {
                case PackageCategory.Installed:
                    if (package.State.HasFlag(PackageState.Disabled))
                        AddButton(Labels.Enable, PackageControlButton.Enable, 0, !isCorePackage);
                    else
                        AddButton(Labels.Disable, PackageControlButton.Disable, 0, !isCorePackage);

                    AddButton(Labels.Uninstall, PackageControlButton.Uninstall, 1, !isCorePackage && !package.State.HasFlag(PackageState.UninstallPending));
                    break;

                case PackageCategory.Online:
                    bool installedOrPending =
                        package.State.HasFlag(PackageState.Installed) ||
                        package.State.HasFlag(PackageState.InstallPending);

                    AddButton(Labels.Install, PackageControlButton.Install, 0, !installedOrPending);
                    break;

                case PackageCategory.Updates:
                    AddButton(Labels.Update, PackageControlButton.Update, 0, !package.State.HasFlag(PackageState.UpdatePending));
                    break;
            }
        }
Exemple #4
0
        public PackageRegistration(IServiceProvider serviceProvider, string packagePath, PackageMetadata metadata, PackageManifest manifest, Guid guid)
        {
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");
            if (packagePath == null)
                throw new ArgumentNullException("packagePath");
            if (metadata == null)
                throw new ArgumentNullException("metadata");
            if (manifest == null)
                throw new ArgumentNullException("manifest");

            Guid = guid;
            _serviceProvider = serviceProvider;
            _packagePath = packagePath;
            Metadata = metadata;
            Manifest = manifest;
        }
Exemple #5
0
        public static void QueueUpdate(ContextName context, PackageMetadata metadata)
        {
            if (context == null)
                throw new ArgumentNullException("context");
            if (metadata == null)
                throw new ArgumentNullException("metadata");

            using (var contextKey = OpenRegistryRoot(true, context))
            using (var packageKey = contextKey.CreateSubKey("InstalledProducts\\" + metadata.Id))
            {
                packageKey.SetValue("NuGetSite", metadata.NuGetSite);
                packageKey.SetValue("GalleryDetailsUrl", metadata.GalleryDetailsUrl);
                packageKey.SetValue("PendingVersion", metadata.Version);
            }
        }
        private void QueueUpdate(PackageMetadata package)
        {
            PackageRegistry.QueueUpdate(_context, package);

            foreach (var dependency in package.Dependencies)
            {
                var dependentPackage = NuGetQuerier.ResolvePackageVersion(_context, _env.NuGetSite, dependency.Id, dependency.Version, PackageStability.StableOnly);

                if (dependentPackage != null)
                    QueueUpdate(dependentPackage);
            }
        }
Exemple #7
0
        private static long GetTotalCount(QueryOperationResponse<V2FeedPackage> response, PackageMetadata[] packageMetadatas)
        {
            // TotalCount may be missing. When this is the case, we default
            // to the number of package meta's we got.

            try
            {
                return response.TotalCount;
            }
            catch (InvalidOperationException)
            {
                return packageMetadatas.Length;
            }
        }