示例#1
0
 /// <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();
     }
 }
示例#2
0
        /// <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);
                }
            }
        }
示例#3
0
 public LanguageTranslator(ILanguageDictionary dictionary, TMP_FontAsset fontAsset)
 {
     this.dictionary = dictionary;
     this.fontAsset  = fontAsset;
 }
示例#4
0
 public LanguagePack(LanguagePackDescription description, ILanguageDictionary languageDictionary)
 {
     Description        = description;
     LanguageDictionary = languageDictionary;
 }
 public GetDefinitionCommand(ILanguageDictionary languageDictionary)
 {
     this.languageDictionary = languageDictionary;
 }
示例#6
0
 private void CheckIsSame(ILanguageDictionary dictionary1, ILanguageDictionary dictionary2)
 {
     Assert.IsTrue(dictionary1.IsSame(dictionary2));
 }
示例#7
0
        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);
        }
示例#8
0
 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));
 }
示例#9
0
        // 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);
        }