Exemple #1
0
        public override String Execute(Context context)
        {
            String str = _expression.Execute(context);

            context.OperatorsList.Add("ConditionCommand - return value - \"" + str + "\"");
            _result = _expression.Execute(context) == "true";
            return(null);
        }
Exemple #2
0
 public override String Execute(Context context)
 {
     context.Variables.Add(_variableName, new Variable(_variableType, _variableValue.Execute(context)));
     context.OperatorsList.Add("CreateVariableCommand - create variable type:" + _variableType +
                               "name: \"" + _variableName +
                               "\"value: \"" + context.Variables[_variableName].Value + "\"");
     return(null);
 }
Exemple #3
0
        public override String Execute(Context context)
        {
            String str = _expression.Execute(context);

            context.ConsoleOutput.Add(str);
            context.OperatorsList.Add("ConsoleLogCommand - print string - " + str);
            return(null);
        }
Exemple #4
0
        public override String Execute(Context context)
        {
            String whereStr = _whereExp.Execute(context);
            String nameStr  = _nameExp.Execute(context);

            Directory.CreateDirectory(@whereStr + nameStr);
            context.OperatorsList.Add("CreateDirCommand - create directory \"" + whereStr + nameStr + "\"");
            return(null);
        }
Exemple #5
0
        public override String Execute(Context context)
        {
            String fileStr = _fileExp.Execute(context);

            if (File.Exists(fileStr))
            {
                File.WriteAllText(@fileStr, "");
                context.OperatorsList.Add("ClearFileCommand - clear file \"" + fileStr + "\"");
            }
            return(null);
        }
Exemple #6
0
        public override String Execute(Context context)
        {
            String fileStr = _fileExp.Execute(context);
            String textStr = _textExp.Execute(context);

            if (File.Exists(fileStr))
            {
                File.AppendAllText(@fileStr, textStr + "\r\n");
                context.OperatorsList.Add("ConsoleLogCommand - write to file \"" + fileStr + "\"");
            }
            return(null);
        }
Exemple #7
0
        public override String Execute(Context context)
        {
            String fileStr = _fileExp.Execute(context);

            if (File.Exists(fileStr))
            {
                String textfile = File.ReadAllText(@fileStr);
                context.OperatorsList.Add("ReadAndLogCommand - read file \"" + fileStr + "\" and log on console");
                context.ConsoleOutput.Add("- Text in file - " + fileStr + "\n - " + textfile);
            }
            return(null);
        }
Exemple #8
0
        public override String Execute(Context context)
        {
            String whereStr = _whereExp.Execute(context);
            String nameStr  = _nameExp.Execute(context);

            if (nameStr.Contains(".txt"))
            {
                FileStream fs = File.Create(@whereStr + nameStr);
                fs.Close();
                context.OperatorsList.Add("CreateTxtFileCommand - Create file \"" + whereStr + nameStr + "\"");
            }
            return(null);
        }
Exemple #9
0
        public override String Execute(Context context)
        {
            String whereStr = _whereExp.Execute(context);
            String whatStr  = _whatExp.Execute(context);

            var files = Directory.EnumerateFileSystemEntries(@whereStr, @whatStr, SearchOption.AllDirectories);

            context.OperatorsList.Add("FindCommand - find - \"" + whatStr + "\" in \n" + whereStr + "\"");

            foreach (var str in files)
            {
                context.ConsoleOutput.Add("File faund  \"" + str + "\"");
            }
            return(null);
        }
Exemple #10
0
        public override String Execute(Context context)
        {
            String pathStr = _pathExp.Execute(context);

            if (Directory.Exists(pathStr))
            {
                context.OperatorsList.Add("LogAllItemsCommand - read all elements from \"" +
                                          pathStr + "\" and log on console");
                var a = Directory.EnumerateFileSystemEntries(@pathStr);
                foreach (var file in a)
                {
                    context.ConsoleOutput.Add("Element - " + file + "\n");
                }
            }
            return(null);
        }
Exemple #11
0
        public override String Execute(Context context)
        {
            String fileStr = _fileExp.Execute(context);

            if (File.Exists(fileStr))
            {
                File.Delete(@fileStr);
                context.OperatorsList.Add("- Delete file - " + fileStr + "\n");
            }
            if (Directory.Exists(fileStr))
            {
                Directory.Delete(@fileStr, true);
                context.OperatorsList.Add("DeleteCommand - delete directory - \"" + fileStr + "\"");
            }
            return(null);
        }
Exemple #12
0
        public override String Execute(Context context)
        {
            Variable var = context.Variables[_variableName];
            String   str = _expression.Execute(context);
            int      e;

            if (!int.TryParse(str, out e) && (var.Type == "int"))
            {
                throw new Exception("Присвоєння рядка числу");
            }
            var.Value = str;
            context.Variables[_variableName] = var;

            context.OperatorsList.Add("AssignmentCommand - variable \"" + _variableName +
                                      "\" assignment value \"" + var.Value + "\"");
            return(null);
        }
Exemple #13
0
        public override String Execute(Context context)
        {
            String fromStr = _fromExp.Execute(context);
            String toStr   = _toExp.Execute(context);

            toStr += fromStr.Substring(fromStr.LastIndexOf("\\"));
            if (File.Exists(fromStr))
            {
                File.Copy(@fromStr, @toStr);
                context.OperatorsList.Add("CopyCommand - copy file \"" + fromStr + " to \n" + toStr + "\"");
            }
            if (Directory.Exists(fromStr))
            {
                CopyDir(fromStr, toStr);
                context.OperatorsList.Add("CopyCommand - copy dir \"" + fromStr + " to \n" + toStr + "\"");
            }
            return(null);
        }
Exemple #14
0
        public override String Execute(Context context)
        {
            String pathStr    = _pathExp.Execute(context);
            String newNameStr = _newName.Execute(context);

            int    i      = pathStr.LastIndexOf("\\", StringComparison.Ordinal);
            String newStr = pathStr.Substring(0, i + 1) + newNameStr;

            if (File.Exists(pathStr))
            {
                File.Move(@pathStr, @newStr);
                context.OperatorsList.Add("RenameCommand - rename file \"" + pathStr + " to \n" + newStr + "\"");
            }
            if (Directory.Exists(pathStr))
            {
                Directory.Move(@pathStr, @newStr);
                context.OperatorsList.Add("RenameCommand - rename dir \"" + pathStr + " to \n" + newStr + "\"");
            }
            return(null);
        }