Beispiel #1
0
        public new void Add(string key, WordInfoOnce value)
        {
            if (ContainsKey(key))
            {
                //$"{name}已存在键:{key}。".WriteWarningLine();
                return;//已有
            }

            if (name == "默认")
            {
                var w = value;
                if (w.p?.StartsWith("i", StringComparison.OrdinalIgnoreCase) == true)
                {
                    Idioms.Add(w.w, w);                                                                  //成语词典
                }
                else if (w.p?.StartsWith("nr", StringComparison.OrdinalIgnoreCase) == true)
                {
                    PersonNames.Add(w.w, w);                                                                        //人名词典
                }
                else if (w.p?.StartsWith("ns", StringComparison.OrdinalIgnoreCase) == true)
                {
                    PlaceNames.Add(w.w, w);                                                                        //地
                }
                else
                {
                    TempWords.Add(key, value);
                }
            }
            else
            {
                base.Add(key, value);
            }
        }
Beispiel #2
0
        public new WordInfoOnce this[string key]
        {
            get {
                if (base.ContainsKey(key))
                {
                    return(base[key]);
                }
                foreach (var dict in subdicts)
                {
                    if (dict?.ContainsKey(key) == true)
                    {
                        return(dict[key]);
                    }
                }
                return(null);
            }
            set {
                if (base.ContainsKey(key))
                {
                    base[key] = value;
                    return;
                }
                foreach (var dict in subdicts)
                {
                    if (dict?.ContainsKey(key) == true)
                    {
                        dict[key] = value;
                        return;
                    }
                }

                //不存在则加到临时库
                if (TempWords.ContainsKey(key))
                {
                    TempWords[key] = value;
                }
                else
                {
                    TempWords.Add(key, value);
                }
            }
        }