Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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)));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 static SettingsWireup()
 {
     Settings = new ConsentSettings();
 }