public void Add(string originalKey, string key, string value, string languageCode) { string[] keyPaths = key.Split(".".ToCharArray()); LauretteBranch branch = root.TraverseAndAddBranches(originalKey, keyPaths, 0); branch.AddTranslation(value, languageCode); if (allLanguageCodes.Contains(languageCode) == false) { allLanguageCodes.Add(languageCode); } }
public void Traverse(Action <LauretteBranch, bool, bool, int> block, int depth) { if (branches.Count == 0) { block(this, true, true, depth); } else { block(this, true, false, depth); foreach (string key in branches.Keys) { LauretteBranch branch = branches [key]; branch.Traverse(block, depth + 1); } block(this, false, false, depth); } }
public LauretteBranch TraverseAndAddBranches(string originalKey, string[] keyPaths, int idx) { if (idx >= keyPaths.Length) { return(this); } string key = keyPaths [idx]; if (branches.ContainsKey(key)) { return(branches [key].TraverseAndAddBranches(originalKey, keyPaths, idx + 1)); } branches [key] = new LauretteBranch(originalKey, key, keyPaths, idx + 1); return(branches [key].TraverseAndAddBranches(originalKey, keyPaths, idx + 1)); }
public LauretteTree() { root = new LauretteBranch("Localizations", "Localizations", null, 0); }