private static void SetString(LangValuesContainer data, string lang, string key, string value) { if (!data.Languages.Contains(lang)) { data.Languages.Add(lang); } if (!data.TextStrings.Contains(key)) { data.TextStrings.Add(key); } // create lang entity ConfigValue txtData = new ConfigValue() { Key = key, Value = value, ValueType = StrType }; var langSection = data.StringsData.FirstOrDefault(x => x.Section == lang); if (langSection == null) { // lang section not created, so we all know what to do ConfigValuesContainer section = new ConfigValuesContainer(lang); section.Array.Add(txtData); data.StringsData.Add(section); } else { langSection.Add(txtData); } }
public Configs() { CustomValues = new ConfigValuesContainer(CustomValuesSectionName); LanguageValues = new LangValuesContainer(); ProxyServers = new List <ProxyValue>(); Dialogs = new DialogsContainer(); }
public LangValuesContainer(TextProcessor textProcessor) { Languages = textProcessor.Languages.ToList(); TextStrings = textProcessor.TextStrings.ToList(); StringsData = new List <ConfigValuesContainer>(); foreach (string lang in Languages) { // in each lang iteration create lang section ConfigValuesContainer langSection = new ConfigValuesContainer(lang); // and finaly build text strings entries foreach (string txt in TextStrings) { ConfigValue txtData = new ConfigValue() { Key = txt, Value = textProcessor[lang, txt], ValueType = StrType, }; langSection.Array.Add(txtData); } StringsData.Add(langSection); } }
/// <summary> /// Build serializeble configs from work data /// </summary> public Configs(BotConfigs configs, DialogsProvider dialogs) { BasicDelay = configs.BasicDelay; BotHash = configs.BotHash; BotName = configs.BotName; CustomValues = new ConfigValuesContainer(configs.GetCustomValues(), CustomValuesSectionName); LanguageValues = new LangValuesContainer(configs.TextStrings); // fill proxies ProxyServers = new List <ProxyValue>(); foreach (var prox in configs.Proxies) { ProxyServers.Add(new ProxyValue(prox)); } Dialogs = new DialogsContainer(dialogs); }