コード例 #1
0
        protected override void Execute_Definition(RoomieCommandContext context)
        {
            var threads         = context.Threads;
            var interpreter     = context.Interpreter;
            var scope           = context.Scope;
            var originalCommand = context.OriginalCommand;
            var innerCommands   = originalCommand.InnerCommands;

            string where = context.ReadParameter("Where").Value;
            string threadName = context.ReadParameter("NewThreadName").Value;
            string path       = context.ReadParameter("Path").Value;

            IEnumerable <IScriptCommand> commandsToAdd;

            if (string.IsNullOrEmpty(path))
            {
                commandsToAdd = innerCommands;
            }
            else
            {
                commandsToAdd = RoomieScript.FromFile(path);
            }

            //TODO: detect when there are no commands?

            switch (where)
            {
            case "End":
                interpreter.CommandQueue.Add(commandsToAdd);
                return;

            case "Here":
                interpreter.CommandQueue.AddBeginning(commandsToAdd);
                return;

            case "New Thread":
                if (string.IsNullOrEmpty(threadName))
                {
                    throw new MissingArgumentsException("NewThreadName");
                }
                RoomieThread newThread = threads.CreateNewThread(threadName, scope);
                newThread.AddCommands(commandsToAdd);
                return;

            default:
                throw new RoomieRuntimeException("Unexpected value for \"Where\" (" + where + ").  Must be set to \"End\", \"Here\", or \"New Thread\"");
            }
        }
コード例 #2
0
 private void RunUserStartupScript()
 {
     //TODO: add a startup script search if DevelopmentEnvironment.
     Print("Searching in \"" + Environment.CurrentDirectory + "\" for \"" + StartupScriptPath + "\"");
     if (File.Exists(StartupScriptPath))
     {
         try
         {
             var script = RoomieScript.FromFile(StartupScriptPath);
             _threadpool.AddCommands(script);
         }
         catch (RoomieRuntimeException exception)
         {
             Print("I had trouble loading the startup script: " + exception.Message);
         }
     }
     else
     {
         //TODO: add a utility function for building single commands
         Print("No Startup Script Found.  Create 'Startup.RoomieScript' in the working directory to use this feature.");
     }
 }