Esempio n. 1
0
        private void dataArrival(SocketCommand CommandToProcess, string ID)
        {
            SocketCommand returnCommand = null;

            // send the command back to the main thread for processing...

            try
            {
                ProcessCommandCallback d = new ProcessCommandCallback(_commandProcessor.ProcessCommand);
                returnCommand = (SocketCommand)this.Dispatcher.Invoke(d, new object[] { CommandToProcess });
            }
            catch (Exception ex)
            {
                returnCommand            = new SocketCommand();
                returnCommand.Command    = Virtual.Engine.Sockets.CommandType.CommandFailed;
                returnCommand.Parameters = new List <CommandParameter>();
                returnCommand.Parameters.Add(new CommandParameter("command", CommandToProcess.ToString()));
            }

            SendData(returnCommand, ID);
        }
Esempio n. 2
0
    /// <summary>
    /// Called to execute the supplied Macro.
    /// </summary>
    /// <param name="commandList">The command list.</param>
    /// <param name="variables">Variable List from calling code.</param>
    /// <param name="procCommand">Callback to the command handler from the calling code.</param>
    public static void ExecuteMacro(string[] commandList, VariableList variables, ProcessCommandCallback procCommand)
    {
      for (int position = 0; position < commandList.Length; position++)
      {
        string command = commandList[position];

        if (command.StartsWith(Common.CmdPrefixIf, StringComparison.OrdinalIgnoreCase))
        {
          string[] commands = Common.SplitIfCommand(command.Substring(Common.CmdPrefixIf.Length));

          if (commands[0].StartsWith(Common.VariablePrefix, StringComparison.OrdinalIgnoreCase))
            commands[0] = variables.GetVariable(commands[0].Substring(Common.VariablePrefix.Length));
          commands[0] = Common.ReplaceSpecialVariables(commands[0]);

          if (commands[2].StartsWith(Common.VariablePrefix, StringComparison.OrdinalIgnoreCase))
            commands[2] = variables.GetVariable(commands[2].Substring(Common.VariablePrefix.Length));
          commands[2] = Common.ReplaceSpecialVariables(commands[2]);

          if (EvaluateIfCommand(commands))
            position = GetLabelPosition(commandList, commands[3]);
          else if (!String.IsNullOrEmpty(commands[4]))
            position = GetLabelPosition(commandList, commands[4]);
        }
        else if (command.StartsWith(Common.CmdPrefixLabel, StringComparison.OrdinalIgnoreCase))
        {
          continue;
        }
        else if (command.StartsWith(Common.CmdPrefixGotoLabel, StringComparison.OrdinalIgnoreCase))
        {
          string label = command.Substring(Common.CmdPrefixGotoLabel.Length);
          position = GetLabelPosition(commandList, label);
        }
        else if (command.StartsWith(Common.CmdPrefixSetVar, StringComparison.OrdinalIgnoreCase))
        {
          string[] commands = Common.SplitSetVarCommand(command.Substring(Common.CmdPrefixSetVar.Length));

          string variable = commands[0].Substring(Common.VariablePrefix.Length);
          string value = Common.ReplaceSpecialVariables(commands[1]);

          variables.SetVariable(variable, value);
        }
        else if (command.Equals(Common.CmdPrefixClearVars, StringComparison.OrdinalIgnoreCase))
        {
          variables.Clear();
        }
        else if (command.StartsWith(Common.CmdPrefixSaveVars, StringComparison.OrdinalIgnoreCase))
        {
          variables.Save(command.Substring(Common.CmdPrefixSaveVars.Length));
        }
        else if (command.StartsWith(Common.CmdPrefixLoadVars, StringComparison.OrdinalIgnoreCase))
        {
          variables.Load(command.Substring(Common.CmdPrefixLoadVars.Length));
        }
        else
        {
          procCommand(command);
        }
      }
    }
Esempio n. 3
0
 /// <summary>
 /// Called to execute the supplied Macro.
 /// </summary>
 /// <param name="fileName">Macro file to process (absolute path).</param>
 /// <param name="variables">Variable List from calling code.</param>
 /// <param name="procCommand">Callback to the command handler from the calling code.</param>
 public static void ExecuteMacro(string fileName, VariableList variables, ProcessCommandCallback procCommand)
 {
   string[] commandList = ReadFromFile(fileName);
   ExecuteMacro(commandList, variables, procCommand);
 }
Esempio n. 4
0
        /// <summary>
        /// Called to execute the supplied Macro.
        /// </summary>
        /// <param name="commandList">The command list.</param>
        /// <param name="variables">Variable List from calling code.</param>
        /// <param name="procCommand">Callback to the command handler from the calling code.</param>
        public static void ExecuteMacro(string[] commandList, VariableList variables, ProcessCommandCallback procCommand)
        {
            for (int position = 0; position < commandList.Length; position++)
            {
                string command = commandList[position];

                if (command.StartsWith(Common.CmdPrefixIf, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitIfCommand(command.Substring(Common.CmdPrefixIf.Length));

                    if (commands[0].StartsWith(Common.VariablePrefix, StringComparison.OrdinalIgnoreCase))
                    {
                        commands[0] = variables.GetVariable(commands[0].Substring(Common.VariablePrefix.Length));
                    }
                    commands[0] = Common.ReplaceSpecialVariables(commands[0]);

                    if (commands[2].StartsWith(Common.VariablePrefix, StringComparison.OrdinalIgnoreCase))
                    {
                        commands[2] = variables.GetVariable(commands[2].Substring(Common.VariablePrefix.Length));
                    }
                    commands[2] = Common.ReplaceSpecialVariables(commands[2]);

                    if (EvaluateIfCommand(commands))
                    {
                        position = GetLabelPosition(commandList, commands[3]);
                    }
                    else if (!String.IsNullOrEmpty(commands[4]))
                    {
                        position = GetLabelPosition(commandList, commands[4]);
                    }
                }
                else if (command.StartsWith(Common.CmdPrefixLabel, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                else if (command.StartsWith(Common.CmdPrefixGotoLabel, StringComparison.OrdinalIgnoreCase))
                {
                    string label = command.Substring(Common.CmdPrefixGotoLabel.Length);
                    position = GetLabelPosition(commandList, label);
                }
                else if (command.StartsWith(Common.CmdPrefixSetVar, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitSetVarCommand(command.Substring(Common.CmdPrefixSetVar.Length));

                    string variable = commands[0].Substring(Common.VariablePrefix.Length);
                    string value    = Common.ReplaceSpecialVariables(commands[1]);

                    variables.SetVariable(variable, value);
                }
                else if (command.Equals(Common.CmdPrefixClearVars, StringComparison.OrdinalIgnoreCase))
                {
                    variables.Clear();
                }
                else if (command.StartsWith(Common.CmdPrefixSaveVars, StringComparison.OrdinalIgnoreCase))
                {
                    variables.Save(command.Substring(Common.CmdPrefixSaveVars.Length));
                }
                else if (command.StartsWith(Common.CmdPrefixLoadVars, StringComparison.OrdinalIgnoreCase))
                {
                    variables.Load(command.Substring(Common.CmdPrefixLoadVars.Length));
                }
                else
                {
                    procCommand(command);
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Called to execute the supplied Macro.
 /// </summary>
 /// <param name="fileName">Macro file to process (absolute path).</param>
 /// <param name="variables">Variable List from calling code.</param>
 /// <param name="procCommand">Callback to the command handler from the calling code.</param>
 public static void ExecuteMacro(string fileName, VariableList variables, ProcessCommandCallback procCommand)
 {
     string[] commandList = ReadFromFile(fileName);
     ExecuteMacro(commandList, variables, procCommand);
 }