Ejemplo n.º 1
0
 private void FileViewModelOnFileChangedOnDisk(IFileViewModel fileViewModel)
 {
     Dictionary<string, List<string>> dictionary = fileViewModel.GetTag("AutoComplete") as Dictionary<string, List<string>>;
       if (dictionary != null)
       {
     foreach (KeyValuePair<string, List<string>> keyValuePair in dictionary)
     {
       m_collections[keyValuePair.Key].Remove(keyValuePair.Value);
     }
     dictionary.Clear();
       }
       Regex scheamRegex = new Regex(@"""\$schema""\s*\:\s*""(.*)""", RegexOptions.IgnoreCase);
       Match match = scheamRegex.Match(fileViewModel.GetContent<string>());
       Schema schema = match.Success ? m_schemaManager.GetSchema(match.Groups[1].ToString()) : null;
       if (schema != null)
       {
     JsonException jsonException;
     JsonNode jsonNode = (JsonNode)JsonHelperFunctions.Parse(fileViewModel.GetContent<string>(), out jsonException);
     if (jsonException == null)
       m_tasks.Add(Task.Factory.StartNew(() => BuildCollection(fileViewModel, jsonNode, schema, new List<string>(), null)));
       }
 }
Ejemplo n.º 2
0
 private void AddRange(string key, IEnumerable<object> value, string prefix, IFileViewModel fileViewModel)
 {
     Dictionary<string, List<string>> dictionary = fileViewModel.GetTag("AutoComplete") as Dictionary<string, List<string>>;
       if (dictionary == null)
       {
     dictionary = new Dictionary<string, List<string>>();
     fileViewModel.SetTag("AutoComplete", dictionary);
       }
       List<string> list;
       dictionary.TryGetValue(key, out list);
       if (list == null)
       {
     list = new List<string>();
     lock (m_collections)
     {
       if (!m_collections.ContainsKey(key))
     m_collections.Add(key, new List<List<string>>());
       m_collections[key].Add(list);
       dictionary.Add(key, list);
     }
       }
       lock (list)
       {
     list.AddRange(value.Select(n => prefix + n.ToString()));
       }
 }