Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 3
0
 public LanguageTranslator(ILanguageDictionary dictionary, TMP_FontAsset fontAsset)
 {
     this.dictionary = dictionary;
     this.fontAsset  = fontAsset;
 }
Ejemplo n.º 4
0
 public LanguagePack(LanguagePackDescription description, ILanguageDictionary languageDictionary)
 {
     Description        = description;
     LanguageDictionary = languageDictionary;
 }
 public GetDefinitionCommand(ILanguageDictionary languageDictionary)
 {
     this.languageDictionary = languageDictionary;
 }
Ejemplo n.º 6
0
 private void CheckIsSame(ILanguageDictionary dictionary1, ILanguageDictionary dictionary2)
 {
     Assert.IsTrue(dictionary1.IsSame(dictionary2));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
        }