private IEnumerable<Document> GetDocuments(string path)
{
if (!IsEnabled || IsLogFileEmpty(path))
yield break;
using (Stream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
string line;
while ((line = reader.ReadLine()) != null)
{
Dictionary<string, AttributeValue> map;
try
{
map = JsonMapper.ToObject<Dictionary<string, AttributeValue>>(line);
}
catch
{
map = null;
}
if (map != null && map.Count > 0)
{
Document doc = Document.FromAttributeMap(map);
yield return doc;
}
}
}
}