/// <summary> /// Initializes a static class that contains static LocalText objects. These objects actually /// contains localized texts in default language, but this method adds them to local text /// dictionary and replaces their values with text keys generated from concatting a prefix /// and the variable name. /// </summary> /// <param name="type">Type to initialize that contains texts</param> /// <param name="prefix">Prefix to add text keys (e.g. "Db.SomeCategory.")</param> public static void InitializeTextClass(Type type, string prefix) { dynamic t = type; foreach (var member in Object.Keys((type)).Clone()) { object value = t[member]; if (Type.IsInstanceOfType(value, typeof(LocalText))) { var lt = value.As<LocalText>(); var key = prefix + member; table[key] = lt.key; t[member] = new LocalText(key); } } }
static LocalText() { Empty = new LocalText(""); }
static Texts() { LocalText.InitializeTextClass(typeof(Dialogs), "Dialogs."); }
static Pager() { LocalText.InitializeTextClass(typeof(Pager), "Controls.Pager."); }
static EntityDialog() { LocalText.InitializeTextClass(typeof(EntityDialog), "Controls.EntityDialog."); }
static EntityGrid() { LocalText.InitializeTextClass(typeof(EntityGrid), "Controls.EntityGrid."); }
static PropertyGrid() { LocalText.InitializeTextClass(typeof(PropertyGrid), "Controls.PropertyGrid."); }
static QuickSearch() { LocalText.InitializeTextClass(typeof(QuickSearch), "Controls.QuickSearch."); }