Exemple #1
0
        public static UiPackageMetadata CreateDetailedPackage(JObject metadata)
        {
            var detailedPackage = new UiPackageMetadata();

            detailedPackage.Version = NuGetVersion.Parse(metadata.Value <string>(Properties.Version));
            string publishedStr = metadata.Value <string>(Properties.Published);

            if (!String.IsNullOrEmpty(publishedStr))
            {
                detailedPackage.Published = DateTime.Parse(publishedStr);
            }

            detailedPackage.Summary        = metadata.Value <string>(Properties.Summary);
            detailedPackage.Description    = metadata.Value <string>(Properties.Description);
            detailedPackage.Authors        = metadata.Value <string>(Properties.Authors);
            detailedPackage.Owners         = metadata.Value <string>(Properties.Owners);
            detailedPackage.IconUrl        = GetUri(metadata, Properties.IconUrl);
            detailedPackage.LicenseUrl     = GetUri(metadata, Properties.LicenseUrl);
            detailedPackage.ProjectUrl     = GetUri(metadata, Properties.ProjectUrl);
            detailedPackage.Tags           = String.Join(" ", (metadata.Value <JArray>(Properties.Tags) ?? Enumerable.Empty <JToken>()).Select(t => t.ToString()));
            detailedPackage.DownloadCount  = metadata.Value <int>(Properties.DownloadCount);
            detailedPackage.DependencySets = (metadata.Value <JArray>(Properties.DependencyGroups) ?? Enumerable.Empty <JToken>()).Select(obj => LoadDependencySet((JObject)obj));

            detailedPackage.HasDependencies = detailedPackage.DependencySets.Any(
                set => set.Dependencies != null && set.Dependencies.Count > 0);

            return(detailedPackage);
        }
        public static UiPackageMetadata CreateDetailedPackage(JObject metadata)
        {            
            var detailedPackage = new UiPackageMetadata();
            detailedPackage.Version = NuGetVersion.Parse(metadata.Value<string>(Properties.Version));
            string publishedStr = metadata.Value<string>(Properties.Published);
            if (!String.IsNullOrEmpty(publishedStr))
            {
                detailedPackage.Published = DateTime.Parse(publishedStr);
            }

            detailedPackage.Summary = metadata.Value<string>(Properties.Summary);
            detailedPackage.Description = metadata.Value<string>(Properties.Description);
            detailedPackage.Authors = metadata.Value<string>(Properties.Authors);
            detailedPackage.Owners = metadata.Value<string>(Properties.Owners);
            detailedPackage.IconUrl = GetUri(metadata, Properties.IconUrl);
            detailedPackage.LicenseUrl = GetUri(metadata, Properties.LicenseUrl);
            detailedPackage.ProjectUrl = GetUri(metadata, Properties.ProjectUrl);
            detailedPackage.Tags = String.Join(" ", (metadata.Value<JArray>(Properties.Tags) ?? Enumerable.Empty<JToken>()).Select(t => t.ToString()));
            detailedPackage.DownloadCount = metadata.Value<int>(Properties.DownloadCount);
            detailedPackage.DependencySets = (metadata.Value<JArray>(Properties.DependencyGroups) ?? Enumerable.Empty<JToken>()).Select(obj => LoadDependencySet((JObject)obj));

            detailedPackage.HasDependencies = detailedPackage.DependencySets.Any(
                set => set.Dependencies != null && set.Dependencies.Count > 0);

            return detailedPackage;
        }