private void OnLoadFileExecute(string fileName)
{
Argument.IsNotNullOrWhitespace(() => fileName);
DroppedFile = fileName;
var fileLines = FileHelper.ReadAllLines(DroppedFile)
.Where(line => !string.IsNullOrWhiteSpace(line));
var lines = fileLines as string[] ?? fileLines.ToArray();
if (!lines.Any())
{
_messageService.ShowInformation(string.Format("The file '{0}' contains no line.", fileName));
return;
}
_pleaseWaitService.Push();
var textToAdd = lines.Aggregate((line1, line2) => string.Format("{0}\n{1}", line1, line2))
.Trim();
if (Document == null)
{
return;
}
if (string.IsNullOrWhiteSpace(Document.Text))
{
Document.Text = textToAdd;
}
else
{
Document.Text += string.Format("\n{0}", textToAdd);
}
if (IsLiveViewEnabled)
{
SubscribeToFileChanges();
}
_pleaseWaitService.Pop();
}