/// <summary> /// 序列化语言包内容; /// </summary> public void Serialize(Stream stream, LanguagePackDescription description, ILanguageDictionary dictionary) { if (dictionary == null) { Serialize(stream, description); } else if (dictionary is LanguageDictionary) { Serialize(stream, description, dictionary as LanguageDictionary); } else if (dictionary is LanguageSplitDictionary) { Serialize(stream, description, dictionary as LanguageSplitDictionary); } else { throw new NotSupportedException(); } }
/// <summary> /// 初始化语言,操作字典等; /// </summary> private void InitializeLanguageDict() { if (CurrentProvider == null) { return; } _languageDict = ServiceProvider.GetInstance <ILanguageDictionary>(); if (_languageDict == null) { return; } _languageDict.ClearMergedDictionaries(); var dicts = new List <ResourceDictionary>(); var providerDirect = $"{AppDomainService.ExecutingAssemblyDirectory}\\{Constants.LanguageDirect}\\{CurrentProvider.Type}"; if (!Directory.Exists(providerDirect)) { return; } var di = new DirectoryInfo(providerDirect); //遍历添加语言文件; foreach (var file in di.GetFiles()) { try { _languageDict.AddMergedDictionaryFromPath($"{providerDirect}/{file.Name}"); } catch (Exception ex) { LoggerService.WriteCallerLine(ex.Message); } } }
public LanguageTranslator(ILanguageDictionary dictionary, TMP_FontAsset fontAsset) { this.dictionary = dictionary; this.fontAsset = fontAsset; }
public LanguagePack(LanguagePackDescription description, ILanguageDictionary languageDictionary) { Description = description; LanguageDictionary = languageDictionary; }
public GetDefinitionCommand(ILanguageDictionary languageDictionary) { this.languageDictionary = languageDictionary; }
private void CheckIsSame(ILanguageDictionary dictionary1, ILanguageDictionary dictionary2) { Assert.IsTrue(dictionary1.IsSame(dictionary2)); }
public static TelegramBotClient GetBotClientAsync(IWordsService wordsService, IUserService userService, IMapper mapper, ILanguageDictionary languageDictionary) { if (botClient != null) { return(botClient); } ConfigureCommands(userService, wordsService, mapper, languageDictionary); wordsService.Timer.Elapsed += new ElapsedEventHandler((sender, args) => SendMessage(wordsService)); botClient = new TelegramBotClient(BotSettings.Key); botClient.OnMessage += OnMessage; botClient.OnCallbackQuery += OnCallbackQuery; botClient.StartReceiving(); return(botClient); }
private static void ConfigureCommands(IUserService userService, IWordsService wordsService, IMapper mapper, ILanguageDictionary languageDictionary) { commandsList = new List <Command>(); commandsList.Add(new HelloComand(wordsService)); commandsList.Add(new CreateWordCommand(wordsService)); commandsList.Add(new StartCommand(userService)); commandsList.Add(new SetShowTimeCommand(userService, mapper)); commandsList.Add(new GetDefinitionCommand(languageDictionary)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IWordsService wordsService, IUserService userService, IMapper mapper, ILanguageDictionary languageDictionary) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); Bot.GetBotClientAsync(wordsService, userService, mapper, languageDictionary); }