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


C# IReport.WriteLine方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:adwardliu,项目名称:dnx,代码行数:39,代码来源:BuildContext.cs

示例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;
            });
        }
开发者ID:leloulight,项目名称:dnx,代码行数:86,代码来源:NuGetPackageUtils.cs

示例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;
                }
            }
        }
开发者ID:noahfalk,项目名称:dnx,代码行数:37,代码来源:PackageUtilities.cs


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