Esempio n. 1
0
 private void AddWordMap(string key, string value)
 {
     lock (_WordMap)
     {
         AutoMessage auto = new AutoMessage()
         {
             Count = 1,
             Text  = value
         };
         List <AutoMessage> list = new List <AutoMessage> ();
         list.Add(auto);
         _WordMap.TryAdd(key, list);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 从字典中获取对话.没有就返回null.
 /// </summary>
 /// <param name="text"></param>
 /// <returns></returns>
 private string GetAutoString(string text)
 {
     lock (_WordMap)
     {
         if (_WordMap.ContainsKey(text))
         {
             IList <AutoMessage> list = _WordMap[text];
             //返回最小的值.
             AutoMessage auto = list[_Random.Next(list.Count - 1)];
             auto.Count++;
             return(auto.Text);
         }
     }
     return(null);
 }
Esempio n. 3
0
        public int CompareTo(object obj)
        {
            AutoMessage auto = obj as AutoMessage;

            if (auto == null)
            {
                throw new ArgumentException("obj");
            }
            if (auto.Count > Count)
            {
                return(1);
            }
            if (auto.Count == Count)
            {
                return(0);
            }
            else
            {
                return(-1);
            }
        }