public NpmPicker(NpmHistory history)
        {
            InitializeComponent();

            _npmHistory = history;

            Title += $"{Resource.Version_Window_Title}: {history.name}";

            GetPackage(history);
        }
        private static NpmHistory FilterLatestVersions(NpmHistory history)
        {
            NpmHistory filteredHistory = new NpmHistory
            {
                name        = history.name,
                description = history.description,
                versions    = new List <string>()
            };

            Version firstVersion   = CrmDeveloperExtensions2.Core.Versioning.StringToVersion(history.versions[0]);
            var     currentMajor   = firstVersion.Major;
            var     currentMinor   = firstVersion.Minor;
            var     currentBuild   = firstVersion.Build;
            var     currentVersion = history.versions[0];

            for (int i = 0; i < history.versions.Count; i++)
            {
                if (i == history.versions.Count - 1)
                {
                    filteredHistory.versions.Add(history.versions[i]);
                }

                Version ver = CrmDeveloperExtensions2.Core.Versioning.StringToVersion(history.versions[i]);

                if (ver.Major > currentMajor)
                {
                    currentMajor = ver.Major;
                    currentMinor = ver.Minor;
                    currentBuild = ver.Build;
                    filteredHistory.versions.Add(currentVersion);
                    currentVersion = history.versions[i];
                    continue;
                }

                if (ver.Minor > currentMinor)
                {
                    currentMinor = ver.Minor;
                    currentBuild = ver.Build;
                    filteredHistory.versions.Add(currentVersion);
                    currentVersion = history.versions[i];
                    continue;
                }

                if (ver.Build > currentBuild)
                {
                    currentVersion = history.versions[i];
                }
            }

            return(filteredHistory);
        }
        private static ListViewItem CreateItem(NpmHistory history, string version)
        {
            ListViewItem item = new ListViewItem
            {
                Content = version,
                Tag     = new NpmPackage
                {
                    Name    = history.name,
                    Version = version
                }
            };

            return(item);
        }
        private void GetPackage(NpmHistory history)
        {
            Versions.Items.Clear();

            if (LimitVersions.ReturnValue())
            {
                history = FilterLatestVersions(history);
            }

            List <string> versions = history.versions.OrderByDescending(s => s).ToList();

            VersionsGrid.Columns[0].Header = history.name;

            foreach (string version in versions)
            {
                var item = CreateItem(history, version);

                Versions.Items.Add(item);
            }

            Versions.SelectedIndex = 0;
        }