コード例 #1
0
        internal static PackageMeta FromNuGet(NuGet.IPackageMetadata metadata)
        {
            var packageMeta = new PackageMeta();

            packageMeta.InitializeFrom(metadata);
            return(packageMeta);
        }
コード例 #2
0
        /// <summary>
        /// Initializes from a nuget package.
        /// </summary>
        /// <param name="metadata">The nuget metadata.</param>
        private void InitializeFrom(NuGet.IPackageMetadata metadata)
        {
            Name    = metadata.Id;
            Version = new PackageVersion(metadata.Version.ToString());
            Title   = metadata.Title;
            Authors.AddRange(metadata.Authors);
            Owners.AddRange(metadata.Owners);
            IconUrl    = metadata.IconUrl;
            LicenseUrl = metadata.LicenseUrl;
            ProjectUrl = metadata.ProjectUrl;
            RequireLicenseAcceptance = metadata.RequireLicenseAcceptance;
            Description  = metadata.Description;
            Summary      = metadata.Summary;
            ReleaseNotes = metadata.ReleaseNotes;
            Language     = metadata.Language;
            Tags         = metadata.Tags;
            Copyright    = metadata.Copyright;

            var dependencySets = metadata.DependencySets.ToList();

            if (dependencySets.Count > 1)
            {
                throw new InvalidOperationException("Metadata loaded from nuspec cannot have more than one group of dependency");
            }

            // Load dependencies
            Dependencies.Clear();
            var dependencySet = dependencySets.FirstOrDefault();

            if (dependencySet != null)
            {
                foreach (var dependency in dependencySet.Dependencies)
                {
                    var packageDependency = new PackageDependency(dependency.Id, PackageVersionRange.FromVersionSpec(dependency.VersionSpec));
                    Dependencies.Add(packageDependency);
                }
            }

            var serverMetaData = metadata as NuGet.IServerPackageMetadata;

            if (serverMetaData != null)
            {
                ReportAbuseUrl = serverMetaData.ReportAbuseUrl;
                DownloadCount  = serverMetaData.DownloadCount;
            }

            var package = metadata as NuGet.IPackage;

            if (package != null)
            {
                IsAbsoluteLatestVersion = package.IsAbsoluteLatestVersion;
                IsLatestVersion         = package.IsLatestVersion;
                Listed    = package.Listed;
                Published = package.Published;
            }
        }
コード例 #3
0
ファイル: PackageMeta.cs プロジェクト: rohitshe/Code
 public static PackageMeta FromNuGet(NuGet.IPackageMetadata metadata)
 {
     var packageMeta = new PackageMeta();
     packageMeta.InitializeFrom(metadata);
     return packageMeta;
 }