Catel.LogAnalyzer.ViewModels.ShellViewModel.OnLoadFileExecute C# (CSharp) Method

OnLoadFileExecute() private method

Method to invoke when the LoadFile command is executed.
private OnLoadFileExecute ( string fileName ) : void
fileName string Name of the file.
return void
        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();
        }