예제 #1
0
        public static LocalizedHtmlString GetTitleOrDefault(this IActivity activity, Func <LocalizedHtmlString> defaultTitle)
        {
            var title = activity.As <ActivityMetadata>().Title;

            // A string used in LocalizedHtmlString won't be encoded so it needs to be pre-encoded.
            // Passing the title as an argument so it uses the HtmlEncoder when rendered
            // Another options would be to use new LocalizedHtmlString(Html.Encode(title)) but it's not available in the current context

            return(!string.IsNullOrEmpty(title) ? new LocalizedHtmlString(nameof(ActivityExtensions.GetTitleOrDefault), "{0}", false, title) : defaultTitle());
        }
예제 #2
0
        public static LocalizedHtmlString GetTitleOrDefault(this IActivity activity, Func <LocalizedHtmlString> defaultTitle)
        {
            var title = activity.As <ActivityMetadata>().Title;

            return(!string.IsNullOrEmpty(title) ? new LocalizedHtmlString(title, title) : defaultTitle());
        }