Example #1
0
        private void GetFileData(string filePath, string extension)
        {
            try
            {
                switch (extension)
                {
                case ".json":
                    var jsonHandler = new JsonHandler(filePath);
                    valuesFromFile = jsonHandler.Handle();
                    break;

                case ".xml":
                    var xmlHandler = new XmlHandler(filePath);
                    valuesFromFile = xmlHandler.Handle();
                    break;

                default:
                    throw new Exception("Данный тип файла не поддерживается");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                valuesFromFile = null;
            }
        }
Example #2
0
 private void JsonFileRead()
 {
     using (StreamReader r = new StreamReader(filePath))
     {
         string json = r.ReadToEnd();
         valueJson = JsonConvert.DeserializeObject <ValuesFromFile>(json);
     }
 }
Example #3
0
        private Dictionary <string, int> SortValue(ValuesFromFile valueForSort)
        {
            var dictionaryForSortValue = new Dictionary <string, int>();

            foreach (var value in valueForSort.Values)
            {
                if (dictionaryForSortValue.ContainsKey(value))
                {
                    dictionaryForSortValue[value]++;
                }
                else
                {
                    dictionaryForSortValue.Add(value, 1);
                }
            }

            return(dictionaryForSortValue);
        }
Example #4
0
 public XmlHandler(string filePath)
 {
     this.filePath = filePath;
     valueXml      = new ValuesFromFile();
 }
Example #5
0
 public FileDispatcher(string[] filePathes)
 {
     this.filePathes     = filePathes;
     valuesFromFile      = new ValuesFromFile();
     fileNamesWithValues = new Dictionary <string, ValuesFromFile>();
 }