public List <T> Read <T>(string filePath, string sheetName) where T : class, new() { var file = _virtualFileProvider.GetFileInfo(filePath); if (!file.Exists) { return(null); } global::Npoi.Mapper.Mapper mapper = new global::Npoi.Mapper.Mapper(file.CreateReadStream()); List <T> sheet = mapper.Take <T>(sheetName).Select(x => x.Value).ToList(); return(sheet); }
public T ReadJson <T>(string filePath) { var result = default(T); var file = _virtualFileProvider.GetFileInfo(filePath); if (!file.Exists) { return(result); } var serializer = new JsonSerializer(); using (var sr = new StreamReader(file.CreateReadStream())) using (var jsonTextReader = new JsonTextReader(sr)) { result = serializer.Deserialize <T>(jsonTextReader); } return(result); }