Example #1
0
        public string Execute(string path)
        {
            StringBuilder messages = new StringBuilder();

            try
            {
                bool isValid = _validateFileType.IsValid(path);
                if (isValid)
                {
                    IEnumerable <string> commands = _fileReader.ReadFile(path);
                    if (commands != null)
                    {
                        foreach (string command in commands)
                        {
                            ICommandExecutor executpr = _provider.InitExecutor(command);
                            string           message  = executpr.ExecuteCommand(command);
                            messages.AppendLine(message);
                        }
                    }
                    else
                    {
                        messages.Append("Invalid file path");
                    }
                }
                else
                {
                    messages.Append("Invalid file type");
                }
                return(messages.ToString());
            }
            catch (Exception ex)
            {
                throw;
            }
        }