Пример #1
0
 public void ConsumeJsonFiles()
 {
     foreach (var jsonFile in jsonFiles)
     {
         using (StreamReader file = File.OpenText(jsonPath + jsonFile + ".json"))
         {
             Console.WriteLine(string.Format("\nAbrindo arquivo {0}.json", jsonFile));
             using (JsonTextReader reader = new JsonTextReader(file))
             {
                 foreach (var molecule in JToken.ReadFrom(reader))
                 {
                     try
                     {
                         var atomsMolecule = GetAtoms(molecule);
                         if (atomsMolecule != null && !FormulasQueue.Contains(atomsMolecule))
                         {
                             FormulasQueue.Enqueue(atomsMolecule);
                         }
                     }
                     catch (Exception) { }
                 }
             }
         }
     }
     Finished = true;
 }
Пример #2
0
 public Dictionary <string, int> GetMolecule()
 {
     try
     {
         lock (queueLock)
         {
             return(FormulasQueue.Dequeue());
         }
     }
     catch (Exception)
     {
         return(new Dictionary <string, int>());
     }
 }