本文整理汇总了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);
}
示例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()
},
};
}
示例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.");
}
示例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
}
}
}
示例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);
}
}
示例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());
}
}
示例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;
}
示例8: RoslynReflector
public RoslynReflector(IPackageMetadata package)
{
_types = new Dictionary<string, TypeModel>();
_namespaces = new Dictionary<string, NamespaceModel>();
_extensions = new Dictionary<string, ExtensionModel>();
_package = package;
}
示例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();
}
示例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()
}
};
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}