Esempio n. 1
0
 public LearnedContent GetLearnedContents()
 {
     if (_learned_contents == null)
     {
         if (File.Exists(_cmd_cache))
         {
             Stream          streamRead = File.OpenRead(_cmd_cache);
             BinaryFormatter binaryRead = new BinaryFormatter();
             try
             {
                 _learned_contents = (LearnedContent)binaryRead.Deserialize(streamRead);
                 if (_learned_contents.KeywordToItem == null || _learned_contents.LearnedItems == null)
                 {
                     _learned_contents = new LearnedContent();
                 }
             }
             catch
             {
                 _learned_contents = new LearnedContent();
             }
             finally
             {
                 streamRead.Close();
                 streamRead.Dispose();
                 binaryRead = null;
             }
         }
         else
         {
             _learned_contents = new LearnedContent();
         }
     }
     return(_learned_contents);
 }
Esempio n. 2
0
 public void AddLearned(string cmd, InterpreterItem.OwnerType type, string content, string[] tokens)
 {
     if (_learned_contents == null)
     {
         _learned_contents = new LearnedContent();
     }
     _learned_contents.AddKeyword(cmd, type, content, tokens);
     SaveLearned(_learned_contents);
 }
Esempio n. 3
0
        public void SaveLearned(LearnedContent learned)
        {
            _learned_contents = null;
            _learned_contents = learned;
            Stream          streamWrite = File.Create(_cmd_cache);
            BinaryFormatter binaryWrite = new BinaryFormatter();

            binaryWrite.Serialize(streamWrite, _learned_contents);
            streamWrite.Close();
            streamWrite.Dispose();
            binaryWrite = null;
        }
Esempio n. 4
0
 public LearnedContent(LearnedContent content)
 {
     _items           = new List <LearnedItem>(content.LearnedItems);
     _keyword_to_item = new Dictionary <string, LearnedItem>(content._keyword_to_item);
 }
Esempio n. 5
0
 public void ClearLearned()
 {
     _learned_contents = new LearnedContent();
     SaveLearned(_learned_contents);
 }