当前位置: 首页>>代码示例>>C#>>正文


C# IPackageMetadata类代码示例

本文整理汇总了C#中IPackageMetadata的典型用法代码示例。如果您正苦于以下问题:C# IPackageMetadata类的具体用法?C# IPackageMetadata怎么用?C# IPackageMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IPackageMetadata类属于命名空间,在下文中一共展示了IPackageMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FromV2Package

 public static PackageLicenseModel FromV2Package(IPackageMetadata package)
 {
     return new PackageLicenseModel(
         package.Id,
         package.LicenseUrl,
         package.Authors);
 }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:7,代码来源:PackageLicenseModel.cs

示例2: Create

 public static Manifest Create(IPackageMetadata metadata)
 {
     return new Manifest
     {
         Metadata = new ManifestMetadata
         {
             Id = metadata.Id.SafeTrim(),
             Version = metadata.Version.ToStringSafe(),
             Title = metadata.Title.SafeTrim(),
             Authors = GetCommaSeparatedString(metadata.Authors),
             Owners = GetCommaSeparatedString(metadata.Owners) ?? GetCommaSeparatedString(metadata.Authors),
             Tags = String.IsNullOrEmpty(metadata.Tags) ? null : metadata.Tags.SafeTrim(),
             LicenseUrl = ConvertUrlToStringSafe(metadata.LicenseUrl),
             ProjectUrl = ConvertUrlToStringSafe(metadata.ProjectUrl),
             IconUrl = ConvertUrlToStringSafe(metadata.IconUrl),
             RequireLicenseAcceptance = metadata.RequireLicenseAcceptance,
             // DevelopmentDependency = metadata.DevelopmentDependency,
             Description = metadata.Description.SafeTrim(),
             Copyright = metadata.Copyright.SafeTrim(),
             Summary = metadata.Summary.SafeTrim(),
             ReleaseNotes = metadata.ReleaseNotes.SafeTrim(),
             Language = metadata.Language.SafeTrim(),
             DependencySets = CreateDependencySets(metadata),
             FrameworkAssemblies = CreateFrameworkAssemblies(metadata),
             ReferenceSets = CreateReferenceSets(metadata),
             MinClientVersionString = metadata.MinClientVersion.ToStringSafe()
         },
     };
 }
开发者ID:nagyistoce,项目名称:dnx,代码行数:29,代码来源:Manifest.cs

示例3: Resolve

        public void Resolve(IPackageMetadata metadata, string folder, string templateName, bool forceUpgrade)
        {
            var gitMetadata = metadata as GitPackageMetadata;
            var protobuildMetadata = metadata as ProtobuildPackageMetadata;
            var folderMetadata = metadata as FolderPackageMetadata;

            if (gitMetadata != null)
            {
                ResolveGit(gitMetadata, folder, templateName, forceUpgrade);
                return;
            }

            if (protobuildMetadata != null)
            {
                ResolveProtobuild(protobuildMetadata, folder, templateName, forceUpgrade);
                return;
            }

            if (folderMetadata != null)
            {
                ResolveFolder(folderMetadata, folder, templateName);
                return;
            }

            throw new InvalidOperationException("Unexpected metadata type " + metadata.GetType().Name + " for source resolve.");
        }
开发者ID:marler8997,项目名称:Protobuild,代码行数:26,代码来源:SourcePackageResolve.cs

示例4: SavePackage

        public static void SavePackage(IPackageMetadata packageMetadata, IEnumerable<IPackageFile> files, string targetFilePath, bool useTempFile)
        {
            var builder = new PackageBuilder();
            // set metadata
            CopyMetadata(packageMetadata, builder);
            // add files
            builder.Files.AddRange(files);

            // create package in the temprary file first in case the operation fails which would
            // override existing file with a 0-byte file.
            string fileNameToUse = useTempFile ? Path.GetTempFileName() : targetFilePath;
            try {
                using (Stream stream = File.Create(fileNameToUse)) {
                    builder.Save(stream);
                }

                if (useTempFile) {
                    File.Copy(fileNameToUse, targetFilePath, true);
                }
            }
            finally {
                try {
                    if (useTempFile && File.Exists(fileNameToUse)) {
                        File.Delete(fileNameToUse);
                    }
                }
                catch {
                    // don't care if this fails
                }
            }
        }
开发者ID:jacksonh,项目名称:nuget,代码行数:31,代码来源:PackageHelper.cs

示例5: PushPackage

        public async Task PushPackage(string apiKey, string filePath, IPackageMetadata package, bool pushAsUnlisted, bool appendV2ApiToUrl)
        {
            string requestUri = CreateRequestUri(appendV2ApiToUrl);

            HttpWebRequest httpRequest = WebRequest.CreateHttp(requestUri);

            httpRequest.Method = "PUT";
            httpRequest.AllowAutoRedirect = true;
            httpRequest.KeepAlive = false;
            httpRequest.Headers.Add(ApiKeyHeader, apiKey);
            httpRequest.UserAgent = _userAgent;
            httpRequest.UseDefaultCredentials = true;
            httpRequest.PreAuthenticate = true;

            var multipartRequest = new MultipartWebRequest();
            multipartRequest.AddFile(new FileInfo(filePath), package.ToString());

            // sending package data asynchronously
            await multipartRequest.CreateMultipartRequest(httpRequest);

            // waiting for response asynchronously
            await EnsureSuccessfulResponse(httpRequest, HttpStatusCode.Created);

            if (pushAsUnlisted)
            {
                await DeletePackageFromServer(apiKey, package.Id, package.Version.ToString(), appendV2ApiToUrl);
            }
        }
开发者ID:campersau,项目名称:NuGetPackageExplorer,代码行数:28,代码来源:GalleryServer.cs

示例6: PushPackage

        public async Task PushPackage(string apiKey, string filePath, IPackageMetadata package, bool pushAsUnlisted)
        {
            string requestUri = EnsureTrailingSlash(_source) + ServiceEndpoint;
            
            HttpWebRequest httpRequest = WebRequest.CreateHttp(requestUri);
            httpRequest.Method = "PUT";
            httpRequest.AllowAutoRedirect = true;
            httpRequest.AllowWriteStreamBuffering = false;
            httpRequest.KeepAlive = false;
            httpRequest.Headers.Add(ApiKeyHeader, apiKey);
            httpRequest.UserAgent = _userAgent;

            var multipartRequest = new MultipartWebRequest();
            multipartRequest.AddFile(new FileInfo(filePath), package.ToString());

            // sending package data asynchronously
            await multipartRequest.CreateMultipartRequest(httpRequest);
            
            // waiting for response asynchronously
            await EnsureSuccessfulResponse(httpRequest, HttpStatusCode.Created);

            if (pushAsUnlisted)
            {
                await DeletePackageFromServer(apiKey, package.Id, package.Version.ToString());
            }
        }
开发者ID:cinecove,项目名称:NuGetPackageExplorer,代码行数:26,代码来源:GalleryServer.cs

示例7: IsSatellitePackage

        public static bool IsSatellitePackage(
            IPackageMetadata package, 
            IPackageRepository repository,
            FrameworkName targetFramework,
            out IPackage runtimePackage)
        {
            // A satellite package has the following properties:
            //     1) A package suffix that matches the package's language, with a dot preceding it
            //     2) A dependency on the package with the same Id minus the language suffix
            //     3) The dependency can be found by Id in the repository (as its path is needed for installation)
            // Example: foo.ja-jp, with a dependency on foo

            runtimePackage = null;

            if (package.IsSatellitePackage())
            {
                string runtimePackageId = package.Id.Substring(0, package.Id.Length - (package.Language.Length + 1));
                PackageDependency dependency = package.FindDependency(runtimePackageId, targetFramework);

                if (dependency != null)
                {
                    runtimePackage = repository.FindPackage(runtimePackageId, versionSpec: dependency.VersionSpec, allowPrereleaseVersions: true, allowUnlisted: true);
                }
            }

            return runtimePackage != null;
        }
开发者ID:aaasoft,项目名称:NuGet.Server,代码行数:27,代码来源:PackageHelper.cs

示例8: RoslynReflector

 public RoslynReflector(IPackageMetadata package)
 {
     _types = new Dictionary<string, TypeModel>();
     _namespaces = new Dictionary<string, NamespaceModel>();
     _extensions = new Dictionary<string, ExtensionModel>();
     _package = package;
 }
开发者ID:digideskio,项目名称:NuGet.PackageIndex,代码行数:7,代码来源:RoslynReflector.cs

示例9: BuildPackage

 public static IPackage BuildPackage(IPackageMetadata metadata, IEnumerable<IPackageFile> files)
 {
     var builder = new PackageBuilder();
     CopyMetadata(metadata, builder);
     builder.Files.AddRange(files);
     return builder.Build();
 }
开发者ID:NuGetPackageExplorer,项目名称:NuGetPackageExplorer,代码行数:7,代码来源:PackageHelper.cs

示例10: Create

 public static Manifest Create(IPackageMetadata metadata)
 {
     return new Manifest {
         Metadata = new ManifestMetadata {
             Id = metadata.Id.SafeTrim(),
             Version = metadata.Version.ToStringSafe(),
             Title = metadata.Title.SafeTrim(),
             Authors = GetCommaSeparatedString(metadata.Authors),
             Owners = GetCommaSeparatedString(metadata.Owners) ?? GetCommaSeparatedString(metadata.Authors),
             Tags = String.IsNullOrEmpty(metadata.Tags) ? null : metadata.Tags.SafeTrim(),
             LicenseUrl = metadata.LicenseUrl != null ? metadata.LicenseUrl.OriginalString.SafeTrim() : null,
             ProjectUrl = metadata.ProjectUrl != null ? metadata.ProjectUrl.OriginalString.SafeTrim() : null,
             IconUrl = metadata.IconUrl != null ? metadata.IconUrl.OriginalString.SafeTrim() : null,
             RequireLicenseAcceptance = metadata.RequireLicenseAcceptance,
             Description = metadata.Description.SafeTrim(),
             Summary = metadata.Summary.SafeTrim(),
             Language = metadata.Language.SafeTrim(),
             Dependencies = metadata.Dependencies == null ||
                            !metadata.Dependencies.Any() ? null :
                            (from d in metadata.Dependencies
                             select new ManifestDependency {
                                 Id = d.Id.SafeTrim(),
                                 Version = d.VersionSpec.ToStringSafe()
                             }).ToList(),
             FrameworkAssemblies = metadata.FrameworkAssemblies == null ||
                                   !metadata.FrameworkAssemblies.Any() ? null :
                                   (from reference in metadata.FrameworkAssemblies
                                    select new ManifestFrameworkAssembly {
                                        AssemblyName = reference.AssemblyName,
                                        TargetFramework = String.Join(", ", reference.SupportedFrameworks.Select(VersionUtility.GetFrameworkString))
                                    }).ToList()
         }
     };
 }
开发者ID:grendello,项目名称:nuget,代码行数:34,代码来源:Manifest.cs

示例11: Equals

 public bool Equals(IPackageMetadata other)
 {
     return Id.Equals(other.Id)
            && Version.Equals(other.Version)
            && LocalPath.Equals(other.LocalPath)
            && AreTargetFrameworksEqual(TargetFrameworks, other.TargetFrameworks)
            && AreAssembliesEqual(Assemblies, other.Assemblies);
 }
开发者ID:digideskio,项目名称:NuGet.PackageIndex,代码行数:8,代码来源:PackageMetadata.cs

示例12: NotifyFileAdded

 public void NotifyFileAdded(IPackageMetadata package, string filepath, PackageType packageType)
 {
     var item = new MruItem {
         Path = filepath.ToLowerInvariant(),
         Id = package.Id,
         Version = package.Version,
         PackageType = packageType
     };
     AddFile(item);
 }
开发者ID:grendello,项目名称:nuget,代码行数:10,代码来源:MruManager.cs

示例13: GetProtobuildPackageBinary

        public void GetProtobuildPackageBinary(IPackageMetadata metadata, out string archiveType, out byte[] packageData)
        {
            var protobuildPackageMetadata = metadata as ProtobuildPackageMetadata;
            if (protobuildPackageMetadata == null)
            {
                throw new InvalidOperationException("Can't call GetProtobuildPackageBinary on non-Protobuild package metadata");
            }

            archiveType = protobuildPackageMetadata.BinaryFormat;
            packageData = GetProtobuildBinaryPackage(protobuildPackageMetadata);
        }
开发者ID:marler8997,项目名称:Protobuild,代码行数:11,代码来源:BinaryPackageResolve.cs

示例14: DownloadPackage

        public IPackage DownloadPackage(IHttpClient downloadClient, byte[] packageHash, IPackageMetadata package)
        {
            if (downloadClient == null)
            {
                throw new ArgumentNullException("downloadClient");
            }
            if (packageHash == null)
            {
                throw new ArgumentNullException("packageHash");
            }
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            // Get the operation display text
            string operation = String.Format(CultureInfo.CurrentCulture, NuGetResources.DownloadProgressStatus, package.Id, package.Version);

            EventHandler<ProgressEventArgs> progressAvailableHandler = (sender, e) =>
            {
                OnPackageDownloadProgress(new ProgressEventArgs(operation, e.PercentComplete));
            };

            EventHandler<WebRequestEventArgs> beforeSendingRequesthandler = (sender, e) =>
            {
                OnSendingRequest(e.Request);
            };

            try
            {
                downloadClient.ProgressAvailable += progressAvailableHandler;
                downloadClient.SendingRequest += beforeSendingRequesthandler;

                // TODO: This gets held onto in memory which we want to get rid of eventually
                byte[] buffer = downloadClient.DownloadData();

                if (!_hashProvider.VerifyHash(buffer, packageHash))
                {
                    throw new InvalidDataException(NuGetResources.PackageContentsVerifyError);
                }

                return _packageFactory.CreatePackage(() =>
                {
                    return new MemoryStream(buffer);
                });
            }
            finally
            {
                downloadClient.ProgressAvailable -= progressAvailableHandler;
                downloadClient.SendingRequest -= beforeSendingRequesthandler;
            }
        }
开发者ID:monoman,项目名称:NugetCracker,代码行数:52,代码来源:PackageDownloader.cs

示例15: DownloadPackage

        public virtual void DownloadPackage(Uri uri, IPackageMetadata package, Stream targetStream)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            var downloadClient = new HttpClient(uri)
                                 {
                                     UserAgent = HttpUtility.CreateUserAgentString(DefaultUserAgentClient)
                                 };
            DownloadPackage(downloadClient, package, targetStream);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:13,代码来源:PackageDownloader.cs


注:本文中的IPackageMetadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。