private DisplayLicenseViewModel SetupInternal( DisplayLicenseViewModel viewModel, Package package, IReadOnlyCollection <CompositeLicenseExpressionSegment> licenseExpressionSegments, string licenseFileContents, User currentUser) { viewModel.EmbeddedLicenseType = package.EmbeddedLicenseType; viewModel.LicenseExpression = package.LicenseExpression; if (PackageHelper.TryPrepareUrlForRendering(package.LicenseUrl, out string licenseUrl)) { viewModel.LicenseUrl = licenseUrl; var licenseNames = package.LicenseNames; if (!string.IsNullOrEmpty(licenseNames)) { viewModel.LicenseNames = licenseNames.Split(',').Select(l => l.Trim()).ToList(); } } viewModel.LicenseExpressionSegments = licenseExpressionSegments; viewModel.LicenseFileContents = licenseFileContents; if (_featureFlagService.IsLicenseMdRenderingEnabled(currentUser) && package.EmbeddedLicenseType == EmbeddedLicenseFileType.Markdown && licenseFileContents != null) { viewModel.LicenseFileContentsHtml = _markdownService.GetHtmlFromMarkdown(licenseFileContents)?.Content; } return(viewModel); }
private DisplayLicenseViewModel Setup( DisplayLicenseViewModel viewModel, Package package, IReadOnlyCollection <CompositeLicenseExpressionSegment> licenseExpressionSegments, string licenseFileContents) { _packageViewModelFactory.Setup(viewModel, package); return(SetupInternal(viewModel, package, licenseExpressionSegments, licenseFileContents)); }
public DisplayLicenseViewModel Create( Package package, IReadOnlyCollection <CompositeLicenseExpressionSegment> licenseExpressionSegments, string licenseFileContents) { var viewModel = new DisplayLicenseViewModel(); return(Setup(viewModel, package, licenseExpressionSegments, licenseFileContents)); }
private DisplayLicenseViewModel SetupInternal( DisplayLicenseViewModel viewModel, Package package, IReadOnlyCollection <CompositeLicenseExpressionSegment> licenseExpressionSegments, string licenseFileContents) { viewModel.EmbeddedLicenseType = package.EmbeddedLicenseType; viewModel.LicenseExpression = package.LicenseExpression; if (PackageHelper.TryPrepareUrlForRendering(package.LicenseUrl, out string licenseUrl)) { viewModel.LicenseUrl = licenseUrl; var licenseNames = package.LicenseNames; if (!string.IsNullOrEmpty(licenseNames)) { viewModel.LicenseNames = licenseNames.Split(',').Select(l => l.Trim()).ToList(); } } viewModel.LicenseExpressionSegments = licenseExpressionSegments; viewModel.LicenseFileContents = licenseFileContents; return(viewModel); }