public async Task <List <T> > GetDataAsync <T>()
        {
            string json;

            using (var streamReader = new StreamReader(await _fileAccessor.ReadFileAsync(GetFileNameFrom(typeof(T)))))
            {
                json = await streamReader.ReadToEndAsync();
            }

            return(await Task.Factory.StartNew(() => JsonConvert.DeserializeObject <List <T> >(json)));
        }
        private async Task ReadDataFromFile(FileUploadModel message, Dictionary <string, decimal> accountBalances)
        {
            var content = await _fileAccessor.ReadFileAsync(new FileUploadModel
            {
                FileName  = message.FileName,
                Extension = message.Extension,
                FileType  = Shared.Enum.FileType.UploadDocument
            });

            for (int i = 0; i < content.Length; i++)
            {
                var      row      = content[i];
                string[] rowArray = row.Split('\t');
                accountBalances.Add(rowArray[0], decimal.Parse(rowArray[1]));
            }
        }
Exemplo n.º 3
0
        private async Task <(bool isValid, string content)> TryGetValidConfigFileAsync(string path)
        {
            var content = await fileAccessor.ReadFileAsync(path);

            try
            {
                string types = JObject.Parse(content).SelectToken("types").ToString();
                return(true, types);
            }
            catch (JsonReaderException)
            {
                throw new InvalidConfigurationFileException(path);
            }
            catch (Exception)
            {
                return(false, null);
            }
        }