public Result TryAdd(string contextId, SqlEmiter emiter) { var fullName = GetFullNameInCurrentNs(contextId); if (Emiters.ContainsKey(fullName)) { return(Result.Fail($"Syntax already defined: '{fullName}'.")); } Emiters.Add(fullName, emiter); return(Result.Ok()); }
public Result <SqlEmiter> TryGetEmiter(string contextId, string currentNs) { var nss = currentNs.Split('.'); for (var i = nss.Length; i >= 0; --i) { var fullName = string.Join(".", nss.Take(i).Concat(new List <string> { contextId })); if (Emiters.ContainsKey(fullName)) { return(Result.Ok(Emiters[fullName])); } } return(Result.Fail <SqlEmiter>($"Syntax '{contextId}' not found in current scope.")); }