public OverlayEndCreditsSectionItemViewModel(OverlayEndCreditsItemViewModel container, OverlayEndCreditsSectionTypeEnum sectionType) : this(container) { this.SectionType = sectionType; this.SectionHTML = OverlayEndCreditsItemModel.SectionHTMLTemplate; if (sectionType == OverlayEndCreditsSectionTypeEnum.Chatters || sectionType == OverlayEndCreditsSectionTypeEnum.Followers || sectionType == OverlayEndCreditsSectionTypeEnum.Hosts || sectionType == OverlayEndCreditsSectionTypeEnum.NewSubscribers || sectionType == OverlayEndCreditsSectionTypeEnum.Subscribers || sectionType == OverlayEndCreditsSectionTypeEnum.Moderators) { this.UserHTML = OverlayEndCreditsItemModel.UserHTMLTemplate; } else if (sectionType == OverlayEndCreditsSectionTypeEnum.FreeFormHTML || sectionType == OverlayEndCreditsSectionTypeEnum.FreeFormHTML2 || sectionType == OverlayEndCreditsSectionTypeEnum.FreeFormHTML3) { this.SectionHTML = OverlayEndCreditsItemModel.FreeFormSectionHTMLTemplate; this.UserHTML = OverlayEndCreditsItemModel.FreeFormUserHTMLTemplate; } else { this.UserHTML = OverlayEndCreditsItemModel.UserDetailsHTMLTemplate; } }
private async Task PerformSectionTemplateReplacement(StringBuilder htmlBuilder, OverlayEndCreditsSectionTypeEnum itemType, Dictionary <UserViewModel, string> replacers, StreamingPlatformTypeEnum platform) { if (this.SectionTemplates.ContainsKey(itemType) && replacers.Count > 0) { OverlayEndCreditsSectionModel sectionTemplate = this.SectionTemplates[itemType]; string sectionHTML = this.PerformTemplateReplacements(sectionTemplate.SectionHTML, new Dictionary <string, string>() { { "NAME", EnumHelper.GetEnumName(itemType) }, { "TEXT_FONT", this.SectionTextFont }, { "TEXT_SIZE", this.SectionTextSize.ToString() }, { "TEXT_COLOR", this.SectionTextColor } }); sectionHTML = await this.ReplaceStringWithSpecialModifiers(sectionHTML, ChannelSession.GetCurrentUser(), new List <string>(), new Dictionary <string, string>(), platform); List <string> userHTMLs = new List <string>(); foreach (var kvp in replacers.OrderBy(kvp => kvp.Key.Username)) { if (!string.IsNullOrEmpty(kvp.Key.Username)) { string userHTML = this.PerformTemplateReplacements(sectionTemplate.UserHTML, new Dictionary <string, string>() { { "NAME", kvp.Key.Username }, { "DETAILS", kvp.Value }, { "TEXT_FONT", this.ItemTextFont }, { "TEXT_SIZE", this.ItemTextSize.ToString() }, { "TEXT_COLOR", this.ItemTextColor } }); userHTML = await this.ReplaceStringWithSpecialModifiers(userHTML, kvp.Key, new List <string>(), new Dictionary <string, string>(), platform); userHTMLs.Add(userHTML); } } htmlBuilder.AppendLine(SectionSeparatorHTML); htmlBuilder.AppendLine(sectionHTML); foreach (string userHTML in userHTMLs) { htmlBuilder.AppendLine(userHTML); } } }