コード例 #1
0
        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);
        }
コード例 #2
0
 private DisplayLicenseViewModel Setup(
     DisplayLicenseViewModel viewModel,
     Package package,
     IReadOnlyCollection <CompositeLicenseExpressionSegment> licenseExpressionSegments,
     string licenseFileContents)
 {
     _packageViewModelFactory.Setup(viewModel, package);
     return(SetupInternal(viewModel, package, licenseExpressionSegments, licenseFileContents));
 }
コード例 #3
0
        public DisplayLicenseViewModel Create(
            Package package,
            IReadOnlyCollection <CompositeLicenseExpressionSegment> licenseExpressionSegments,
            string licenseFileContents)
        {
            var viewModel = new DisplayLicenseViewModel();

            return(Setup(viewModel, package, licenseExpressionSegments, licenseFileContents));
        }
コード例 #4
0
        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);
        }