Beispiel #1
0
        public ShortCodeLoader(ILog log, IReadonlyRuntimeSettings settings, IAppSetting appSetting)
        {
            _log          = log;
            _settings     = settings;
            _tranlsations = settings.Configuration.Translations;
            _appSetting   = appSetting;

            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new TypeCatalog(typeof(ILog),
                                                 typeof(IReadonlyRuntimeSettings),
                                                 typeof(IAppSetting)));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(ShortCodeLoader).Assembly));
            Imports    = new List <ITemplateShortCode>();
            _container = new CompositionContainer(catalog);
        }
Beispiel #2
0
        public static string DoTranslateForKey(IReadOnlyTranslations translations, string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return(string.Empty);
            }

            if (!TranslateCheck.IsMatch(key))
            {
                return($"Invalid tranlation key: {key}");
            }
            else if (translations.ContainsKey(key))
            {
                return(translations[key]);
            }
            else
            {
                return($"translation not found: '{key}'");
            }
        }
Beispiel #3
0
 public Translate(IReadOnlyTranslations translations)
 {
     _translations = translations;
 }