public string RenderNotificationHtml(ConsentSettings settings, string htmlContent, string culture, bool isDebug) { var cookieContent = _storage.Read(COOKIE_KEY); return(string.IsNullOrEmpty(cookieContent) ? GenerateConsentHtml(settings, htmlContent, culture, isDebug) : string.Empty); }
private string GenerateConsentHtml(ConsentSettings settings, string htmlContent, string culture, bool isDebug) { if (string.IsNullOrWhiteSpace(culture) || !settings.LocalizedContentSettings.ContainsKey(culture)) { culture = settings.FallbackCulture; } if (isDebug) { return(ApplyTemplate(settings, htmlContent, culture)); } return(CachedConsentHtml.GetOrAdd(culture, x => ApplyTemplate(settings, htmlContent, culture))); }
private static string ApplyTemplate(ConsentSettings settings, string htmlContent, string culture) { var template = htmlContent; var mappings = settings.GetMappings(culture.ToLower()); if (mappings == null) { throw new Exception("Can't find culture and fallback culture"); } foreach (var mapping in mappings) { template = template.Replace(string.Format("{{{0}}}", mapping.Key), mapping.Value); } return(template); }
static SettingsWireup() { Settings = new ConsentSettings(); }