コード例 #1
0
        public static Package ConvertToPackage(Version version)
        {
            var metadataWrapper = new MetadataWrapper(version.Metadata);

            var package = new Package
            {
                Id      = version.Project,
                Version = version.Name,


                Title                    = metadataWrapper["Title"],
                Authors                  = metadataWrapper["Authors"],
                Copyright                = metadataWrapper["Copyrights"],
                Description              = metadataWrapper["Description"],
                IconUrl                  = metadataWrapper["IconUrl"],
                LicenseUrl               = metadataWrapper["LicenseUrl"],
                ProjectUrl               = metadataWrapper["ProjectUrl"],
                ReleaseNotes             = metadataWrapper["RequireLicenseAcceptance"],
                RequireLicenseAcceptance = (metadataWrapper["LicenseUrl"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase),
                Summary                  = metadataWrapper["Summary"],
                Tags                    = metadataWrapper["Tags"],
                Dependencies            = metadataWrapper["Dependencies"],
                PackageHash             = metadataWrapper["PackageHash"] ?? version.PackageHash,
                PackageHashAlgorithm    = metadataWrapper["PackageHashAlgorithm"] ?? "SHA512",
                PackageSize             = int.Parse(metadataWrapper["PackageSize"] ?? "-1"),
                DownloadCount           = int.Parse(metadataWrapper["DownloadCount"] ?? "0"),
                LastUpdated             = DateTime.UtcNow,
                Published               = DateTime.UtcNow,
                IsLatestVersion         = (metadataWrapper["IsLatestVersion"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase),
                IsAbsoluteLatestVersion = (metadataWrapper["IsLatestVersion"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase),
            };

            return(package);
        }
コード例 #2
0
        public static Package ConvertToPackage(Version version)
        {
            var metadataWrapper = new MetadataWrapper(version.Metadata);

            var package = new Package
                              {
                                  Id = version.Project,
                                  Version = version.Name,


                                  Title = metadataWrapper["Title"],
                                  Authors = metadataWrapper["Authors"],
                                  Copyright = metadataWrapper["Copyrights"],
                                  Description = metadataWrapper["Description"],
                                  IconUrl = metadataWrapper["IconUrl"],
                                  LicenseUrl = metadataWrapper["LicenseUrl"],
                                  ProjectUrl = metadataWrapper["ProjectUrl"],
                                  ReleaseNotes = metadataWrapper["RequireLicenseAcceptance"],
                                  RequireLicenseAcceptance = (metadataWrapper["LicenseUrl"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase),
                                  Summary = metadataWrapper["Summary"],
                                  Tags = metadataWrapper["Tags"],
                                  Dependencies = metadataWrapper["Dependencies"],
                                  PackageHash =  metadataWrapper["PackageHash"] ?? version.PackageHash,
                                  PackageHashAlgorithm = metadataWrapper["PackageHashAlgorithm"] ?? "SHA512",
                                  PackageSize = int.Parse(metadataWrapper["PackageSize"] ?? "-1"),
                                  DownloadCount = int.Parse(metadataWrapper["DownloadCount"] ?? "0"),
                                  LastUpdated = DateTime.UtcNow,
                                  Published = DateTime.UtcNow,
                                  IsLatestVersion = (metadataWrapper["IsLatestVersion"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase),
                                  IsAbsoluteLatestVersion = (metadataWrapper["IsLatestVersion"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase),
                              };

            return package;
        }
コード例 #3
0
 private string GetPackagePathFromVersion(Version version, string packageFormat)
 {
     // ReSharper disable ReplaceWithSingleCallToFirstOrDefault
     return(GetPackageNameCandidates(version, packageFormat)
            .Select(name => Path.Combine(version.Project, version.Name, name))
            .Where(candidate => File.Exists(Path.Combine(configuration.DataPath, candidate)))
            .FirstOrDefault());
     // ReSharper restore ReplaceWithSingleCallToFirstOrDefault
 }
コード例 #4
0
        public string Download(Caller caller, string company, string repository, string projectName, string versionName, string contentType)
        {
            var container = new Version {
                Company = company, Repository = repository, Project = projectName, Name = versionName
            };

            using (var session = backendFactory.Create(caller))
                return(session.GetPackageLink(ref container, contentType));
        }
コード例 #5
0
 private string GetPackagePathFromVersion(Version version, string packageFormat)
 {
     // ReSharper disable ReplaceWithSingleCallToFirstOrDefault
     return GetPackageNameCandidates(version, packageFormat)
         .Select(name => Path.Combine(version.Project, version.Name, name))
         .Where(candidate => File.Exists(Path.Combine(configuration.DataPath, candidate)))
         .FirstOrDefault();
     // ReSharper restore ReplaceWithSingleCallToFirstOrDefault
 }
コード例 #6
0
        private IEnumerable <string> GetPackageNameCandidates(Version version, string packageFormat)
        {
            if (packageFormat != null)
            {
                return new[] { GetPackageName(packageFormat, version.Project, version.Name) }
            }
            ;

            return(new[] { GetPackageName("NuGet", version.Project, version.Name) });
        }
コード例 #7
0
        private IEnumerable<string> GetPackageNameCandidates(Version version, string packageFormat)
        {
            if (packageFormat != null)
                return new[] { GetPackageName(packageFormat, version.Project, version.Name) };

            return new[]
                       {
                           GetPackageName("NuGet", version.Project, version.Name),
                           GetPackageName("OpenWrap", version.Project, version.Name)
                       };
        }
コード例 #8
0
 public virtual void DeleteVersion(Version version)
 {
     service.DeleteVersion(caller, version);
 }
コード例 #9
0
 public virtual void CreateVersion(Version version)
 {
     service.CreateVersion(caller, ref version);
 }
コード例 #10
0
 public virtual void UpdateVersion(Version version)
 {
     service.UpdateVersion(caller, ref version);
 }
コード例 #11
0
 public virtual void DeleteVersion(Version version)
 {
     throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name);
 }
コード例 #12
0
        public static Version ConvertToVersion(IPackage package)
        {
            var version = new Version
            {
                Project = package.Id,
                Name    = package.Version.ToString(),
            };

            var metadata        = new List <MetadataEntry>();
            var metadataWrapper = new MetadataWrapper(metadata);

            if (!package.Authors.IsEmpty())
            {
                metadataWrapper["Authors"] = String.Join(",", package.Authors);
            }

            if (!string.IsNullOrEmpty(package.Copyright))
            {
                metadataWrapper["Copyrights"] = package.Copyright;
            }

            if (!string.IsNullOrEmpty(package.Description))
            {
                metadataWrapper["Description"] = package.Description;
            }

            if (package.IconUrl != null)
            {
                metadataWrapper["IconUrl"] = package.IconUrl.ToString();
            }

            if (!string.IsNullOrEmpty(package.Language))
            {
                metadataWrapper["Language"] = package.Language;
            }

            if (package.LicenseUrl != null)
            {
                metadataWrapper["LicenseUrl"] = package.LicenseUrl.ToString();
            }

            if (!package.Owners.IsEmpty())
            {
                metadataWrapper["Owners"] = String.Join(",", package.Owners);
            }

            if (package.ProjectUrl != null)
            {
                metadataWrapper["ProjectUrl"] = package.ProjectUrl.ToString();
            }

            if (!string.IsNullOrEmpty(package.ReleaseNotes))
            {
                metadataWrapper["ReleaseNotes"] = package.ReleaseNotes;
            }

            metadataWrapper["RequireLicenseAcceptance"] = package.RequireLicenseAcceptance.ToString();

            if (!string.IsNullOrEmpty(package.Summary))
            {
                metadataWrapper["Summary"] = package.Summary;
            }

            if (!string.IsNullOrEmpty(package.Tags))
            {
                metadataWrapper["Tags"] = package.Tags;
            }

            if (package.DependencySets.SelectMany(ConvertDependencySetToStrings).Any())
            {
                metadataWrapper["Dependencies"] = String.Join("|", package.DependencySets.SelectMany(ConvertDependencySetToStrings));
            }

            if (!string.IsNullOrEmpty(package.Title))
            {
                metadataWrapper["Title"] = package.Title;
            }

            using (var stream = package.GetStream())
            {
                metadataWrapper["PackageSize"]          = stream.Length.ToString();
                metadataWrapper["PackageHashAlgorithm"] = "SHA512";

                stream.Seek(0, SeekOrigin.Begin);
                using (var hasher = new SHA512Managed())
                    metadataWrapper["PackageHash"] = Convert.ToBase64String(hasher.ComputeHash(stream));
            }

            metadataWrapper["DownloadCount"] = "000000";
            metadataWrapper["CreatedDate"]   = DateTime.UtcNow.ToString("s");

            version.Metadata = metadata.ToArray();

            return(version);
        }
コード例 #13
0
 public virtual Version SetVersionHidden(ref Version version, bool hidden)
 {
     throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name);
 }
コード例 #14
0
 public UploadReport UploadPackage(PackageProject package, string packageFormat, byte[] packageData, byte[] symbolPackageData)
 {
     //TODO: quick and dirty
     try
     {
         var version = new Version {Company = caller.Company, Repository = package.Repository, Project = package.Name, Name = package.Version.Name};
         CreateVersion(version);
         PushPackage(ref version, packageData, package);
         CreateJob(symbolPackageData, package);
         return new UploadReport { Summary = "OK" };
     }
     catch(Exception e)
     {
         return new UploadReport
                    {
                        Summary = "Error",
                        Exception = e.ToString(),
                    };                
     }
 }
コード例 #15
0
 public Compilation[] GetCompilationList(ref Version version)
 {
     throw new NotImplementedException();
 }
コード例 #16
0
 public virtual void SetVersionPermissions(User targetUser, Version version, Permission permission)
 {
     throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name);
 }
コード例 #17
0
 public virtual void SetVersionPermissions(User targetUser, Version version, Permission permission)
 {
     service.SetVersionPermissions(caller, targetUser, version, permission);
 }
コード例 #18
0
 public virtual string GetPackageLink(ref Version version, string contentType)
 {
     return service.GetPackageLink(caller, ref version, contentType);
 }
コード例 #19
0
 public string GetPackageLink(ref Version version, string contentType)
 {
     return configuration.RemotePath + '/' + GetPackagePathFromVersion(version, null).Replace(Path.DirectorySeparatorChar, '/');
 }
コード例 #20
0
 public virtual string GetPackageLink(ref Version version, string contentType)
 {
     throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name);
 }
コード例 #21
0
 public virtual void PushPackage(ref Version version, byte[] package, PackageProject packageProject)
 {
     throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name);
 }
コード例 #22
0
 public virtual Version SetVersionHidden(ref Version version, bool hidden)
 {
     return service.SetVersionHidden(caller, ref version, hidden);
 }
コード例 #23
0
 public virtual VersionPermission[] GetVersionPermissions(Version version)
 {
     throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name);
 }
コード例 #24
0
 public virtual VersionPermission[] GetVersionPermissions(Version version)
 {
     return service.GetVersionPermissions(caller, version);
 }
コード例 #25
0
 public virtual Compilation[] GetCompilationList(ref Version version)
 {
     throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name);
 }
コード例 #26
0
 public virtual Compilation[] GetCompilationList(ref Version version)
 {
     return service.GetCompilationList(caller, ref version);
 }
コード例 #27
0
        public static Version ConvertToVersion(Stream stream)
        {
            var package = new ZipPackage(stream);
            stream = package.GetStream();

            var version = new Version
                              {
                                  Project = package.Id,
                                  Name = package.Version.ToString(),
                              };

            var metadata = new List<MetadataEntry>();
            var metadataWrapper = new MetadataWrapper(metadata);

            if (!package.Authors.IsEmpty())
                metadataWrapper["Authors"] = String.Join(",", package.Authors);

            if (!string.IsNullOrEmpty(package.Copyright))
                metadataWrapper["Copyrights"] = package.Copyright;

            if (!string.IsNullOrEmpty(package.Description))
                metadataWrapper["Description"] = package.Description;

            if (package.IconUrl != null)
                metadataWrapper["IconUrl"] = package.IconUrl.ToString();

            if (!string.IsNullOrEmpty(package.Language))
                metadataWrapper["Language"] = package.Language;

            if (package.LicenseUrl != null)
                metadataWrapper["LicenseUrl"] = package.LicenseUrl.ToString();

            if (!package.Owners.IsEmpty())
                metadataWrapper["Owners"] = String.Join(",", package.Owners);

            if (package.ProjectUrl != null)
                metadataWrapper["ProjectUrl"] = package.ProjectUrl.ToString();

            if (!string.IsNullOrEmpty(package.ReleaseNotes))
                metadataWrapper["ReleaseNotes"] = package.ReleaseNotes;

            metadataWrapper["RequireLicenseAcceptance"] = package.RequireLicenseAcceptance.ToString();

            if (!string.IsNullOrEmpty(package.Summary))
                metadataWrapper["Summary"] = package.Summary;

            if (!string.IsNullOrEmpty(package.Tags))
                metadataWrapper["Tags"] = package.Tags;

            if (package.DependencySets.SelectMany(ConvertDependencySetToStrings).Any())
                metadataWrapper["Dependencies"] = String.Join("|", package.DependencySets.SelectMany(ConvertDependencySetToStrings));

            if (!string.IsNullOrEmpty(package.Title))
                metadataWrapper["Title"] = package.Title;

            metadataWrapper["PackageSize"] = stream.Length.ToString();
            metadataWrapper["PackageHashAlgorithm"] = "SHA512";

            stream.Seek(0, SeekOrigin.Begin);
            using (var hasher = new SHA512Managed())
                    metadataWrapper["PackageHash"] = Convert.ToBase64String(hasher.ComputeHash(stream));

            metadataWrapper["DownloadCount"] = "000000";
            metadataWrapper["CreatedDate"] = DateTime.UtcNow.ToString("s");

            version.Metadata = metadata.ToArray();

            return version;
        }
コード例 #28
0
 public void CreateVersion(Version version)
 {
 }
コード例 #29
0
 public void CreateVersion(Version version)
 {
 }
コード例 #30
0
 public void SetVersionHidden(ref Version version, bool hidden)
 {
     throw new NotImplementedException();
 }
コード例 #31
0
 public Compilation[] GetCompilationList(ref Version version)
 {
     throw new NotImplementedException();
 }
コード例 #32
0
 public void SetVersionHidden(ref Version version, bool hidden)
 {
     throw new NotImplementedException();
 }
コード例 #33
0
 public string GetPackageLink(ref Version version, string contentType)
 {
     return(configuration.RemotePath + '/' + GetPackagePathFromVersion(version, null).Replace(Path.DirectorySeparatorChar, '/'));
 }