using System;
using System.Windows.Input;

namespace Valg.EVA.Skanning.UserInterfaceElements.MessageBox
{
    public class ErrorSolutionWithCommand
    {
        private readonly ICommand command;
        private readonly string commandText;
        private readonly string solutionText;

        public ErrorSolutionWithCommand(string entireSolutionText, ICommand possibleSolutionCommand)
        {
            command = possibleSolutionCommand;

            var splitOnCommandKeyword = entireSolutionText.Split(new[] { "<command>" }, StringSplitOptions.None);

            if (splitOnCommandKeyword.Length > 0)
            {
                solutionText = splitOnCommandKeyword[0];
            }

            if (splitOnCommandKeyword.Length > 1)
            {
                commandText = splitOnCommandKeyword[1].Split(new[] {"</command>"}, StringSplitOptions.None)[0];
            }
        }

        public ICommand Command
        {
            get { return command; }
        }
        public string CommandText
        {
            get { return commandText; }
        }
        public string SolutionText
        {
            get { return solutionText; }
        }
    }
}
