本文整理汇总了C#中IReport.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# IReport.WriteLine方法的具体用法?C# IReport.WriteLine怎么用?C# IReport.WriteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReport
的用法示例。
在下文中一共展示了IReport.WriteLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDependencyInformation
private void ShowDependencyInformation(IReport report)
{
// Make lookup for actual package dependency assemblies
var projectExport = _libraryExporter.GetAllExports(_project.Name);
if (projectExport == null)
{
return;
}
var metadataFileRefs = projectExport.MetadataReferences
.OfType<IMetadataFileReference>();
foreach (var library in _libraryManager.GetLibraryDescriptions())
{
if (!library.Resolved)
{
report.WriteLine(" Unable to resolve dependency {0}", library.Identity.ToString().Red().Bold());
report.WriteLine();
continue;
}
report.WriteLine(" Using {0} dependency {1}", library.Type, library.Identity);
report.WriteLine(" Source: {0}", HighlightFile(library.Path));
if (library.Type == LibraryTypes.Package)
{
// TODO: temporarily use prefix to tell whether an assembly belongs to a package
// Should expose LibraryName from IMetadataReference later for more efficient lookup
var libraryPath = NormalizeDirectoryPath(library.Path);
var packageAssemblies = metadataFileRefs.Where(x => Path.GetFullPath(x.Path).StartsWith(libraryPath));
foreach (var assembly in packageAssemblies)
{
var relativeAssemblyPath = PathUtility.GetRelativePath(
libraryPath,
Path.GetFullPath(assembly.Path));
report.WriteLine(" File: {0}", relativeAssemblyPath.Bold());
}
}
report.WriteLine();
}
}
示例2: InstallFromStream
internal static async Task InstallFromStream(
Stream stream,
LibraryIdentity library,
string packagesDirectory,
IReport information,
string packageHash = null)
{
var packagePathResolver = new DefaultPackagePathResolver(packagesDirectory);
var targetPath = packagePathResolver.GetInstallPath(library.Name, library.Version);
var targetNuspec = packagePathResolver.GetManifestFilePath(library.Name, library.Version);
var targetNupkg = packagePathResolver.GetPackageFilePath(library.Name, library.Version);
var targetHashPath = packagePathResolver.GetHashPath(library.Name, library.Version);
// Acquire the lock on a nukpg before we extract it to prevent the race condition when multiple
// processes are extracting to the same destination simultaneously
await ConcurrencyUtilities.ExecuteWithFileLocked(targetNupkg, action: async _ =>
{
if (string.IsNullOrEmpty(packageHash))
{
using (var sha512 = SHA512.Create())
{
packageHash = Convert.ToBase64String(sha512.ComputeHash(stream));
}
}
var actionName = "Installing";
var installedPackageHash = string.Empty;
if (File.Exists(targetHashPath) && File.Exists(targetNuspec))
{
installedPackageHash = File.ReadAllText(targetHashPath);
actionName = "Overwriting";
}
if (string.Equals(packageHash, installedPackageHash, StringComparison.Ordinal))
{
information.WriteLine($"{library.Name}.{library.Version} already exists");
}
else
{
information.WriteLine($"{actionName} {library.Name}.{library.Version}");
Directory.CreateDirectory(targetPath);
using (var nupkgStream = new FileStream(
targetNupkg,
FileMode.Create,
FileAccess.ReadWrite,
FileShare.ReadWrite | FileShare.Delete,
bufferSize: 4096,
useAsync: true))
{
stream.Seek(0, SeekOrigin.Begin);
await stream.CopyToAsync(nupkgStream);
nupkgStream.Seek(0, SeekOrigin.Begin);
ExtractPackage(targetPath, nupkgStream);
}
// Fixup the casing of the nuspec on disk to match what we expect
var nuspecFile = Directory.EnumerateFiles(targetPath, "*" + NuGet.Constants.ManifestExtension).Single();
Manifest manifest = null;
using (var nuspecStream = File.OpenRead(nuspecFile))
{
manifest = Manifest.ReadFrom(nuspecStream, validateSchema: false);
manifest.Metadata.Id = library.Name;
manifest.Metadata.Version = library.Version;
}
// Delete the previous nuspec file
File.Delete(nuspecFile);
// Write the new manifest
using (var targetNuspecStream = File.OpenWrite(targetNuspec))
{
manifest.Save(targetNuspecStream);
}
// Note: PackageRepository relies on the hash file being written out as the final operation as part of a package install
// to assume a package was fully installed.
File.WriteAllText(targetHashPath, packageHash);
}
return 0;
});
}
示例3: OpenNuspecStreamFromNupkgAsync
internal static async Task<Stream> OpenNuspecStreamFromNupkgAsync(PackageInfo package,
Func<PackageInfo, Task<Stream>> openNupkgStreamAsync,
IReport report)
{
using (var nupkgStream = await openNupkgStreamAsync(package))
{
try {
using (var archive = new ZipArchive(nupkgStream, ZipArchiveMode.Read, leaveOpen: true))
{
var entry = archive.GetEntryOrdinalIgnoreCase(package.Id + ".nuspec");
using (var entryStream = entry.Open())
{
var nuspecStream = new MemoryStream((int)entry.Length);
#if DNXCORE50
// System.IO.Compression.DeflateStream throws exception when multiple
// async readers/writers are working on a single instance of it
entryStream.CopyTo(nuspecStream);
#else
await entryStream.CopyToAsync(nuspecStream);
#endif
nuspecStream.Seek(0, SeekOrigin.Begin);
return nuspecStream;
}
}
}
catch (InvalidDataException)
{
var fileStream = nupkgStream as FileStream;
if (fileStream != null)
{
report.WriteLine("The ZIP archive {0} is corrupt",
fileStream.Name.Yellow().Bold());
}
throw;
}
}
}