コード例 #1
0
        public void AddInputPromptWordCite(string txt)
        {
            if (txt.xIsNullOrEmptyOrSpace())
            {
                return;
            }

            if (_prompDict.ContainsKey(txt))
            {
                var prompt = _prompDict.xTryGetValue(txt, null);
                if (prompt != null)
                {
                    prompt.UpdateLatestUse(txt);
                }
            }
            else
            {
                var wdDict     = WordSpliter.Split(txt, true);
                int wordsCount = wdDict.Values.Sum(k => k.Count);
                if (wordsCount > 0)
                {
                    var prompt = InputPromptString.Create(txt, wordsCount, wdDict, null);
                    if (_prompDict.TryAdd(txt, prompt))
                    {
                        foreach (var w in wdDict)
                        {
                            GetInputPromptWordCite(w.Key).Add(prompt);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void AddOrUpdateInputPromptWordCite(ShortcutEntity shortcut)
        {
            if (shortcut == null || (string.IsNullOrEmpty(shortcut.Title) && string.IsNullOrEmpty(shortcut.Text)))
            {
                return;
            }
            var text = string.Concat(shortcut.Code, " ", shortcut.Title, " ", shortcut.Text);

            text = text.Trim().ToLower();
            var key = shortcut.Text.xToBanJiaoAndRemoveCharThatAsciiValueLessThan32AndToLower();

            if (_prompDict.ContainsKey(key))
            {
                var prompt = _prompDict.xTryGetValue(key, null);
                if (prompt != null)
                {
                    prompt.AddUseCount(1);
                }
            }
            else
            {
                var wdDict    = WordSpliter.Split(text, true);
                int wordCount = wdDict.Values.Sum(k => k.Count);
                if (wordCount > 0)
                {
                    var prompt = InputPromptString.Create(text, wordCount, wdDict, shortcut);
                    if (_prompDict.TryAdd(key, prompt))
                    {
                        foreach (var w in wdDict)
                        {
                            GetInputPromptWordCiteData(w.Key).Add(prompt);
                        }
                    }
                }
            }
        }