private static void RegisterTypesInNamespace(string ns) { JsDictionary nsObj = Window.Instance.As <JsDictionary>(); foreach (var x in ns.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)) { nsObj = nsObj[x].As <JsDictionary>(); if (nsObj == null) { return; } } foreach (var k in Object.Keys(nsObj)) { var obj = nsObj.As <JsDictionary>()[k]; if (obj == null) { continue; } string name = ns + "." + k; visited[name] = true; if (Script.TypeOf(obj) == "function") { var type = Type.GetType(name); if (type == null) { continue; } var attr = type.GetCustomAttributes(typeof(EditorAttribute), true); if (attr != null && attr.Length > 0) { RegisterType(type); } } else { RegisterTypesInNamespace(name); continue; } } }
private JsDictionary <string, TEntity> GetPendingLocalizations() { if (localizationPendingValue == null) { return(null); } var result = new JsDictionary <string, TEntity>(); string idField = GetIdProperty(); var langs = GetLanguages(); var langsArr = (langs as object) as string[][]; if (langsArr != null && langsArr.Length > 0 && langsArr[0] != null && Q.IsArray(langsArr[0])) { langs = langsArr.Select(x => new Tuple <string, string>(x[0], x[1])); } foreach (var pair in langs) { var language = pair.Item1; var entity = new JsDictionary <string, object>(); if (idField != null) { entity[idField] = this.EntityId; } var prefix = language + "$"; foreach (var k in localizationPendingValue.Keys) { if (k.StartsWith(prefix)) { entity[k.Substr(prefix.Length)] = localizationPendingValue[k]; } } result[language] = entity.As <TEntity>(); } return(result); }
private JsDictionary <string, TEntity> GetPendingLocalizations() { if (localizationPendingValue == null) { return(null); } var result = new JsDictionary <string, TEntity>(); string idField = GetIdProperty(); var langsTuple = GetLanguages(); var langs = (langsTuple as object) as string[][]; if (langs == null || langs.Length == 0 || langs[0] == null || !Q.IsArray(langs[0])) { langs = langsTuple.Select(x => new string[] { x.Item1, x.Item2 }).ToArray(); } foreach (var pair in langs) { var language = pair[0]; var entity = new JsDictionary <string, object>(); if (idField != null) { entity[idField] = this.EntityId; } var prefix = language + "$"; foreach (var k in localizationPendingValue.Keys) { if (k.StartsWith(prefix)) { entity[k.Substr(prefix.Length)] = localizationPendingValue[k]; } } result[language] = entity.As <TEntity>(); } return(result); }
/// <summary> /// Use to add local text to dictionary /// </summary> /// <param name="obj">Object with local text list in a format like Enums:{WeekDays:{Monday: 'Pazartesi', ... }}} to /// "Enums.WeekDays.Monday" = "Pazartesi"</param> /// <param name="prefix">Prefix to add to all keys</param> /// <remarks>Obj is provided in a compact format to keep size as small as possible.</remarks> public static void Add(JsDictionary <string, object> obj, string prefix) { if (!Script.IsValue(obj)) { return; } prefix = prefix ?? ""; foreach (var k in obj.As <JsDictionary>().Keys) { var actual = prefix + k; var o = obj[k]; if (Script.TypeOf(o) == "object") { Add(o.As <JsDictionary>(), actual + "."); } else { table[actual] = o.As <string>(); } } }
private JsDictionary <string, TEntity> GetPendingLocalizations() { if (localizationPendingValue == null) { return(null); } var result = new JsDictionary <string, TEntity>(); string idField = GetEntityIdField(); foreach (var pair in GetLanguages()) { var language = pair.Item1; var entity = new JsDictionary <string, object>(); if (idField != null) { entity[idField] = this.EntityId; } var prefix = language + "$"; foreach (var k in localizationPendingValue.Keys) { if (k.StartsWith(prefix)) { entity[k.Substr(prefix.Length)] = localizationPendingValue[k]; } } result[language] = entity.As <TEntity>(); } return(result); }