コード例 #1
0
        public static CommandList GetCommands(Assembly assembly)
        {
            // Any static classes containing commands for use from the 
            // console are located in the Commands namespace. Load 
            // references to each type in that namespace via reflection:
            var commands = new CommandList();

            // Use reflection to load all of the classes in the Commands namespace:
            var current = Assembly.GetExecutingAssembly();
            var q = from t in current.GetTypes()
                    where t.IsClass
                    && typeof(IConsoleCommand).IsAssignableFrom(t)
                    select t;
            var defaultCommands = GetCommands(q, current);
            foreach (var command in defaultCommands.Where(command => !command.Key.Namespace.Contains("get_Info")))
            {
                commands.Add(command.Key, command.Value);
            }
           
            var user = from t in assembly.GetTypes()
                       where t.IsClass
                       && typeof(IConsoleCommand).IsAssignableFrom(t)
                       select t;

            var userCommands = GetCommands(user, assembly);
            foreach (var command in userCommands)
            {
                commands.Add(command.Key, command.Value);
            }

            return commands;
        }
コード例 #2
0
ファイル: TextBox.cs プロジェクト: Ju2ender/csharp-e
 protected virtual void InitMenu()
 {
     if (Menu == null)
     {
         Menu = new CommandList();
         Menu.Add(new CutCommand(this));
         Menu.Add(new CopyCommand(this));
         Menu.Add(new PasteCommand(this));
     }
 }
コード例 #3
0
        private static CommandList GetCommands(IEnumerable<Type> commandClasses, Assembly assembly)
        {
            var commands = new CommandList();
            foreach (var commandClass in commandClasses)
            {
                var instance = (IConsoleCommand)Activator.CreateInstance(commandClass);
                // Load the method info from each class into a dictionary:
                var methods = commandClass.GetMethods(BindingFlags.Public | BindingFlags.Instance);
                var methodDictionary = new Dictionary<string, ConsoleExecutingMethod>();
                foreach (var method in methods)
                {
                    var commandName = method.Name;
                    if (commandName.Contains("get_Info")) continue;
                    if (method.ReturnParameter != null && method.DeclaringType != null &&
                        method.ReturnParameter.ParameterType.FullName.Contains("ConsoleShared.ConsoleExecuteResult"))
                    {
                        methodDictionary.Add(commandName,
                            new ConsoleExecutingMethod(method.DeclaringType.Namespace, assembly,
                                method.GetParameters(), IsAsyncMethod(method)));
                    }
                }

                // Add the dictionary of methods for the current class into a dictionary of command classes:
                commands.Add(new ConsoleExecutingAssembly(commandClass.Name, instance), methodDictionary);
            }
            return commands;
        }
コード例 #4
0
        /// <inheritdoc />
        partial void AddPlatformCommands()
        {
            LtoFlashGroupCommand.MenuParent = RootCommandGroup.ToolsMenuCommand;
            LtoFlashGroupCommand.Weight     = 0.8;
            CommandList.Add(LtoFlashGroupCommand);
            CommandList.Add(LtoFlashGroupCommand.CreateSeparator(CommandLocation.Before));

            CommandList.Remove(FtdiDriverVersionCommand);
        }
コード例 #5
0
        /// <summary>
        /// Adds the platform-specific commands.
        /// </summary>
        partial void AddPlatformCommands()
        {
            FirmwareGroupCommand.MenuParent = LtoFlashCommandGroup.LtoFlashGroupCommand;
            RestoreFirmwareCommand.Weight   = 0.1;
            CommandList.Add(CheckForFirmwareUpdateCommand.CreateSeparator(CommandLocation.Before));

            CommandList.Add(FirmwareGroupCommand);
            CommandList.Add(FirmwareGroupCommand.CreateSeparator(CommandLocation.After));
        }
コード例 #6
0
 public void AddCommand(byte command)
 {
     command = (byte)Convert.ToInt32(command + "", 16);
     if (command < 0)//Make custom exception
     {
         throw new Exception("Command must be a positive number");
     }
     CommandList.Add(command);
 }
コード例 #7
0
        public void ExecuteConfirm()
        {
            IsEnabledField = false;
            IsEnabledCC    = false;
            IsInDeleteMode = false;
            try
            {
                switch (_selectedCommand)
                {
                case CommandType.AddMaterial:
                    DetailedContent.Time = DateTime.Now;
                    CommandMaterial cmd = DetailedContent.Command as CommandMaterial;
                    if (cmd.Material != null)
                    {
                        _warehouse.DBService.FindMaterialID(cmd.Material.Value, true);
                    }
                    _warehouse.DBService.AddCommand(cmd);
                    CommandList.Add(DetailedContent);
                    break;

                case CommandType.AddSegment:
                    DetailedContent.Time = DateTime.Now;
                    _warehouse.DBService.AddCommand(DetailedContent.Command as CommandSegment);
                    CommandList.Add(DetailedContent);
                    break;

                case CommandType.Restart:
                    DetailedContent.Time   = DateTime.Now;
                    DetailedContent.Status = EnumCommandStatus.Waiting;
                    _warehouse.DBService.UpdateCommand(DetailedContent.Command);
                    break;

                case CommandType.Delete:
                    _warehouse.DBService.UpdateCommand(DetailedContent.Command);
                    _warehouse.DBService.AddCommand(new CommandCommand
                    {
                        Task      = Command.EnumCommandTask.CancelCommand,
                        CommandID = DetailedContent.ID,
                        Priority  = 0,
                        Status    = Command.EnumCommandStatus.NotActive,
//                            Reason = DetailedContent.Command.Reason,
                        Time = DateTime.Now
                    });
                    break;

                default:
                    break;
                }
                DetailedContent.ValidationEnabled = false;
                DetailedContent = SelectedContent;
            }
            catch (Exception e)
            {
                _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception,
                                    string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
            }
        }
コード例 #8
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Adds a line.
 /// </summary>
 public int AddLine(string lineToAdd)
 {
     if (lineToAdd == null)
     {
         return(100);
     }
     CommandList.Add(lineToAdd);
     return(0);
 }
コード例 #9
0
 public void UpdateList([NotNull] List <ObservableCommand> cmdList)
 {
     // set the current commandlist to be displayed in the listview
     CommandList.Clear();
     foreach (var x in cmdList)
     {
         CommandList.Add(x);
     }
 }
コード例 #10
0
 /// <summary>
 /// Add GTK-specific commands.
 /// </summary>
 partial void AddPlatformCommands()
 {
     CommandList.Add(FileMenuCommand);
     CommandList.Add(EditMenuCommand);
     CommandList.Add(ViewMenuCommand);
     CommandList.Add(ToolsMenuCommand);
     CommandList.Add(WindowMenuCommand);
     CommandList.Add(HelpMenuCommand);
 }
コード例 #11
0
 private void InitializeCommand(RoutedUICommand command, Func <bool> isVisibleHandler, Func <bool> isEnabledHandler, Func <bool> isCheckedHandler, Action commandHandler)
 {
     CommandList.Add(command);
     MenuHeaderTable.Add(command, command.Text);
     MenuIsVisibleTable.Add(command, isVisibleHandler);
     MenuIsEnabledTable.Add(command, isEnabledHandler);
     MenuIsCheckedTable.Add(command, isCheckedHandler);
     MenuHandlerTable.Add(command, commandHandler);
 }
コード例 #12
0
 /// <inheritdoc />
 protected override void AddCommands()
 {
     UpdateDriverVersionCommandStrings(INTV.LtoFlash.Utility.FTDIUtilities.DriverVersionString);
     CommandList.Add(FtdiGroupCommand);
     CommandList.Add(FtdiDriverVersionCommand);
     CommandList.Add(GoToFTDIDriverPageCommand);
     ////CommandList.Add(LaunchFtdiDriverInstallerCommand); // Not worth it. Lots of problems on Mac (signing) and probably old.
     AddPlatformCommands();
 }
コード例 #13
0
        public void SNIPE_InitCommands()
        {
            // GA
            CommandList.Add(new Command("ga", 0, Command.Behaviour.Normal,
                                        (sender, arguments, optarg) =>
            {
                if (Call <string>("getdvar", "g_gametype") == "infect" && sender.GetTeam() == "axis")
                {
                    WriteChatToPlayer(sender, "I like the way you're thinking, but nope.");
                    return;
                }
                CMD_GiveMaxAmmo(sender);
                WriteChatToPlayer(sender, Command.GetString("ga", "message"));
            }));

            // HIDEBOMBICON
            CommandList.Add(new Command("hidebombicon", 0, Command.Behaviour.Normal,
                                        (sender, arguments, optarg) =>
            {
                CMD_HideBombIconAndSmoke(sender);
                WriteChatToPlayer(sender, Command.GetString("hidebombicon", "message"));
            }));

            // KNIFE
            CommandList.Add(new Command("knife", 1, Command.Behaviour.Normal,
                                        (sender, arguments, optarg) =>
            {
                bool enabled = UTILS_ParseBool(arguments[0]);
                CMD_knife(enabled);
                if (enabled)
                {
                    WriteChatToAll(Command.GetString("knife", "message_on"));
                }
                else
                {
                    WriteChatToAll(Command.GetString("knife", "message_off"));
                }
            }));

            // LETMEHARDSCOPE
            CommandList.Add(new Command("letmehardscope", 1, Command.Behaviour.Normal,
                                        (sender, arguments, optarg) =>
            {
                bool state = UTILS_ParseBool(arguments[0]);
                if (state)
                {
                    sender.SetField("letmehardscope", 1);
                    WriteChatToPlayer(sender, Command.GetString("letmehardscope", "message_on"));
                }
                else
                {
                    sender.SetField("letmehardscope", 0);
                    WriteChatToPlayer(sender, Command.GetString("letmehardscope", "message_off"));
                }
            }));
        }
コード例 #14
0
ファイル: RootCommandGroup.cs プロジェクト: intvsteve/VINTage
        /// <inheritdoc />
        protected override void AddCommands()
        {
            CommandList.Add(RootCommand);
            CommandList.Add(RootMenuCommand);
            CommandList.Add(ApplicationMenuCommand);
#if DEBUG
            CommandList.Add(DebugCommandGroup.DebugMenuCommand);
#endif // DEBUG
            AddPlatformCommands();
        }
コード例 #15
0
 public IEnumerable <GameCommandBase> GetActionCommands()
 {
     CommandList.Clear();
     foreach (var obj in GameObjects)
     {
         CommandList.AddRange(obj.GetActionCommands());
     }
     CommandList.Add(new QuitGameCommand(this));
     return(CommandList);
 }
コード例 #16
0
ファイル: CommandSpec.cs プロジェクト: beccasaurus/Crack
        public void can_match_commands_with_certain_text_from_a_CommandList()
        {
            var list = new CommandList();

            list.Add(new Command(Method("Foo"))
            {
                Name = "foo"
            });
            list.Add(new Command(Method("Foo"))
            {
                Name = "foot"
            });

            list.Match("f").Select(cmd => cmd.Name).ToArray().ShouldEqual(new string[] { "foo", "foot" });
            list.Match("fo").Select(cmd => cmd.Name).ToArray().ShouldEqual(new string[] { "foo", "foot" });
            list.Match("foo").Select(cmd => cmd.Name).ToArray().ShouldEqual(new string[] { "foo" });            // EXACT MATCH, so we don't return foot // TODO change this ... if using Match, user can check if any of the results are a command via list.IsCommand("") ... or we need to add something like that.  this result is currently unintuitive.
            list.Match("foot").Select(cmd => cmd.Name).ToArray().ShouldEqual(new string[] { "foot" });
            list.Match("foott").Select(cmd => cmd.Name).ToArray().ShouldEqual(new string[] {  });
        }
コード例 #17
0
        public MainWindow()
        {
            InitializeComponent();

            usbCon          = new USBConnection("COM3");
            camCon          = new NikonController("Type0014.md3");
            camCon.SaveToPc = true;
            cl = new CommandList();
            cl.Add(new Command(Command.Cmdtype.PHOTO));
        }
コード例 #18
0
ファイル: TheManager.cs プロジェクト: HowDoesOneMath/Engines1
 public void AddCommand(BaseCommand bc)
 {
     if (CurrentCommand < CommandList.Count - 1)
     {
         RemoveUndos();
     }
     CommandList.Add(bc);
     CurrentCommand++;
     TrimCommandList();
 }
コード例 #19
0
ファイル: Sbc.cs プロジェクト: wowjinxy/nitro-g3d-tools
 public Sbc(byte[] sbc)
 {
     using (var er = new EndianBinaryReaderEx(new MemoryStream(sbc), Endianness.LittleEndian))
     {
         while (er.BaseStream.Position < er.BaseStream.Length)
         {
             CommandList.Add(SbcCommand.Read(er));
         }
     }
 }
コード例 #20
0
        /// <summary>
        /// 绑定命令类型
        /// </summary>
        /// <param name="id"></param>
        /// <param name="commandType"></param>
        /// <param name="handleResult"></param>
        public void BindCommandModel(int id, AdvertManage.Model.Enum.CommandType commandType, AdvertManage.Model.Enum.CommandHandleResult handleResult)
        {
            CommandList.Clear();
            List <AdvertManage.Model.AMS_CommandListModel> cmdList = AdvertManage.BLL.AMS_CommandBLL.GetCommandListByCondition(id, commandType, handleResult);

            foreach (AdvertManage.Model.AMS_CommandListModel model in cmdList)
            {
                CommandList.Add(model);
            }
        }
コード例 #21
0
        private void InitializeCommand(string header, Func <bool> isVisibleHandler, Func <bool> isEnabledHandler, Func <bool> isCheckedHandler, Action commandHandler)
        {
            ICommand Command = new RoutedUICommand();

            CommandList.Add(Command);
            MenuHeaderTable.Add(Command, header);
            MenuIsVisibleTable.Add(Command, isVisibleHandler);
            MenuIsEnabledTable.Add(Command, isEnabledHandler);
            MenuIsCheckedTable.Add(Command, isCheckedHandler);
            MenuHandlerTable.Add(Command, commandHandler);
        }
コード例 #22
0
ファイル: QLearning.cs プロジェクト: ProductOfPrimes/Fox-Two
    /// <summary>
    /// Convert abstract command list that just references them by this commander's list of planes into a command list with specific Aircraft
    /// </summary>
    /// <param name="commander"></param>
    /// <param name="commands"></param>
    /// <returns></returns>
    CommandList CommandListAbstractToConcrete(CommandListAbstract commands, Commander commander)
    {
        CommandList concreteCommands = new CommandList();

        for (int i = 0; i < commands.Count; i++)
        {
            Maneuver maneuver = Maneuver.BasicManeuvers[(short)commands[i]];
            concreteCommands.Add(commander.unitsCommanded[i], maneuver);
        }
        return(concreteCommands);
    }
コード例 #23
0
 /// <inheritdoc/>
 protected override void AddCommands()
 {
     CommandList.Add(DownloadAndPlayCommand);
     CommandList.Add(DownloadAndPlayPromptCommand);
     CommandList.Add(SyncHostToDeviceCommand);
     CommandList.Add(SyncDeviceToHostCommand);
     CommandList.Add(SyncHostToDevicePreviewCommand);
     CommandList.Add(SyncDeviceToHostPreviewCommand);
     CommandList.Add(SyncClearChangesPreviewCommand);
     AddPlatformCommands();
 }
コード例 #24
0
 /// <summary>
 /// Adds the platform-specific commands.
 /// </summary>
 partial void AddPlatformCommands()
 {
     OpenSettingsDialogCommand.MenuParent     = JzIntvLauncherCommandGroup.JzIntvToolsMenuCommand;
     OpenSettingsDialogCommand.Weight         = 0.5;
     ShowGettingStartedCommand.MenuParent     = JzIntvLauncherCommandGroup.JzIntvToolsMenuCommand;
     ShowGettingStartedCommand.Weight         = 0.51;
     ShowInstalledDocumentsCommand.MenuParent = JzIntvLauncherCommandGroup.JzIntvToolsMenuCommand;
     ShowInstalledDocumentsCommand.Weight     = 0.52;
     CommandList.Add(ShowGettingStartedCommand);
     CommandList.Add(ShowInstalledDocumentsCommand);
 }
コード例 #25
0
        private void InitializeCommand(string header, Func <bool> isVisibleHandler, Func <bool> isEnabledHandler, Func <bool> isCheckedHandler, Action commandHandler)
        {
            string   LocalizedText = Properties.Resources.ResourceManager.GetString(header, CultureInfo.CurrentCulture) !;
            ICommand Command       = new RoutedUICommand(LocalizedText, header, GetType());

            CommandList.Add(Command);
            MenuHeaderTable.Add(Command, LocalizedText);
            MenuIsVisibleTable.Add(Command, isVisibleHandler);
            MenuIsEnabledTable.Add(Command, isEnabledHandler);
            MenuIsCheckedTable.Add(Command, isCheckedHandler);
            MenuHandlerTable.Add(Command, commandHandler);
        }
コード例 #26
0
        public static void Run(List <_Command> cmdlist)
        {
            Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Registering commands..");
            CommandList.Clear();
            foreach (var command in cmdlist)
            {
                if (DebugLevel >= 1)
                {
                    Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Registering command: {command.CommandName}..");
                }
                Action <SvPlayer, string> rMethod = null;
                try
                {
                    rMethod = (Action <SvPlayer, string>)
                              Delegate.CreateDelegate(typeof(Action <SvPlayer, string>),
                                                      Type.GetType($"BP_Essentials.Commands.{command.CommandName}")
                                                      .GetMethod(nameof(Run)));
                }
                catch (ArgumentException)
                {
                    rMethod = null;
                }
                if (command.CommandName == "ToggleReceiveStaffChat")
                {
                    CmdStaffChatExecutableBy = command.ExecutableBy;
                }
                if (command.CommandName == "Confirm")
                {
                    CmdConfirm = command.Commands[0];
                }
                if (command.CommandName == "ToggleChat")
                {
                    CmdToggleChat = command.Commands[0];
                }
                if (command.CommandName == "TpaAccept")
                {
                    CmdTpaaccept = command.Commands[0];
                }
                CommandList.Add(CommandList.Count + 1, new _CommandList {
                    RunMethod = rMethod,

                    commandGroup              = command.ExecutableBy ?? "everyone",
                    commandName               = command.CommandName,
                    commandCmds               = command.Commands.Select(x => $"{CmdCommandCharacter}{x}").ToList(),
                    commandDisabled           = command.Disabled ?? false,
                    commandWantedAllowed      = command.AllowWithCrimes ?? true,
                    commandHandcuffedAllowed  = command.AllowWhileCuffed ?? true,
                    commandWhileJailedAllowed = command.AllowWhileJailed ?? true
                });
            }
            Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Registered commands! ({CommandList.Count} commands loaded in.)");
        }
コード例 #27
0
 public void AddCommand(String command)
 {
     if (System.Text.RegularExpressions.Regex.IsMatch(command, @"\A\b[0-9a-fA-F]+\b\Z"))
     {
         int hexNum = Convert.ToInt32(command, 16);
         CommandList.Add((byte)hexNum);
     }
     else
     {
         //Make custom exception
         throw new Exception("Not a valid Hex string");
     }
 }
コード例 #28
0
        public ComponentPage(ComponentViewModel vm)
        {
            InitializeComponent();
            BindingContext = vm;

            CType ctype = vm.CType.AsCType();

            if (ctype.IsAny(CType.Element))
            {
                if (ctype.IsAny(CType.Digital))
                {
                    DigitalFunctions.IsVisible = true;
                }
                if (ctype.IsAny(CType.Analog))
                {
                    AnalogFunctions.IsVisible = true;
                }
            }

            if (!DigitalFunctions.IsVisible)
            {
                PageStack.Children.Remove(DigitalFunctions);
            }
            if (!AnalogFunctions.IsVisible)
            {
                PageStack.Children.Remove(AnalogFunctions);
            }

            bool noCommands = true;

            foreach (var command in vm.Commands)
            {
                CommandList.Add(CreateLabel(command));
                noCommands = false;
            }

            if (noCommands)
            {
                ArgumentList.UserControllable = false;
                StackLayout stack = btnSendCommand.Parent as StackLayout;
                if (stack != null)
                {
                    stack.Children.Remove(btnSendCommand);
                }
            }
            else
            {
                vm.ViewGenerator = CreateEntry;
            }
        }
コード例 #29
0
        /// <summary>
        /// WPF-specific command setup.
        /// </summary>
        partial void AddPlatformCommands()
        {
            ShowJzIntvCommandLineCommand.UseXamlResource = true;
            ShowJzIntvCommandLineCommand.Weight          = 0.5;
            ShowJzIntvCommandLineCommand.VisualParent    = ConfigurationCommandGroup.ConfigurationRibbonGroupCommand;

            CommandList.Add(JzIntvRibbonTabCommand);
            CommandList.Add(LaunchRibbonGroupCommand);
            CommandList.Add(LaunchInJzIntvRibbonSplitButtonCommand);
            CommandList.Add(LaunchInJzIntvRibbonButtonCommand.CreateRibbonMenuSeparator(CommandLocation.Before, false));
            CommandList.Add(LaunchInJzIntvRibbonButtonCommand);
            CommandList.Add(BrowseAndLaunchInJzIntvRibbonButtonCommand);
            CommandList.Add(ShowJzIntvCommandLineCommand);
        }
コード例 #30
0
        private void PhotoTestButton_Click(object sender, RoutedEventArgs e)
        {
            var clTest = new CommandList();

            clTest.Add(new Command(Command.Cmdtype.TIME, 400));
            if (VisButton.IsChecked == true)
            {
                clTest.Add(new Command(Command.Cmdtype.VISIBLE, 45));
            }
            else if (IrButton.IsChecked == true)
            {
                clTest.Add(new Command(Command.Cmdtype.INFRARED, 45));
            }
            else
            {
                clTest.Add(new Command(Command.Cmdtype.ULTRAVIOLET, 45));
            }
            clTest.Add(new Command(Command.Cmdtype.PHOTO));
            if (sendThread == null || !sendThread.IsAlive)
            {
                sendThread = new Thread(() => clTest.Send(usbCon, camCon));
                sendThread.Start();
            }
        }
コード例 #31
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if (time != (int.Parse(LedTimeBox.Text)))
            {
                cl.Add(new Command(Command.Cmdtype.TIME, int.Parse(LedTimeBox.Text) / 10));
                time = int.Parse(LedTimeBox.Text);
            }
            if (IrButton.IsChecked == true)
            {
                cl.Add(new Command(Command.Cmdtype.INFRARED, (int)LedNumberBox.SelectedItem));
            }
            if (VisButton.IsChecked == true)
            {
                cl.Add(new Command(Command.Cmdtype.VISIBLE, (int)LedNumberBox.SelectedItem));
            }
            if (UvButton.IsChecked == true)
            {
                cl.Add(new Command(Command.Cmdtype.ULTRAVIOLET, (int)LedNumberBox.SelectedItem));
            }

            CmdBox.ItemsSource = cl.ToStringList();
            CmdBox.Items.Refresh();
            LedNumberBox.SelectedIndex = 0;
        }
コード例 #32
0
        private void AddRange(CommandList list, IReadOnlyList <Command> commands)
        {
            if (commands == null)
            {
                return;
            }

            foreach (var command in commands)
            {
                if (command != null)
                {
                    list.Add(command);
                }
            }
        }
コード例 #33
0
 /// <inheritdoc />
 protected override void AddCommands()
 {
     CommandList.Add(RomListGroupCommand);
     CommandList.Add(AddRomFilesCommand);
     CommandList.Add(AddRomFoldersCommand);
     CommandList.Add(RemoveRomsCommand);
     CommandList.Add(ValidateRomsCommand);
     CommandList.Add(RefreshRomsCommand);
     CommandList.Add(CancelRomsImportCommand);
     CommandList.Add(ShowRomInfoCommand);
     CommandList.Add(EditProgramNameCommand);
     CommandList.Add(BackupRomListCommand);
     CommandList.Add(RestoreRomListCommand);
     CommandList.Add(EmptyRomListCommand);
     AddPlatformCommands();
 }
コード例 #34
0
ファイル: Program.cs プロジェクト: hunpody/psimulex
        /// <summary>
        /// Joins every user-defined function to the end of the command list.
        /// After calling this function you should NOT change the command list.
        /// </summary>
        public void JoinCommands()
        {
            if (!isJoined)
            {
                originalCommandList = CommandList;
                CommandList = new CommandList();
                CommandList.AddRange(originalCommandList);
                if (CommandList.Count > 0 && !(CommandList.Last() is Return))
                {
                    CommandList.Add(new Return(false));
                }
                //EntryPoints.Clear();
                foreach (var udf in Functions)
                {
                    //EntryPoints.Add(udf, CommandList.Count);
                    udf.EntryPoint = CommandList.Count;
                    CommandList.AddRange(udf.Commands);
                }

                isJoined = true;
            }
        }
コード例 #35
0
ファイル: Delete.cs プロジェクト: Ju2ender/csharp-e
 public static void Add(CommandList menu, Block toDelete)
 {
     menu.Add(new DeleteCommand(toDelete));
 }
コード例 #36
0
ファイル: Delete.cs プロジェクト: Ju2ender/csharp-e
 public static CommandList CreateDeleteMenu(Block toDelete)
 {
     CommandList result = new CommandList();
     result.Add(new DeleteCommand(toDelete));
     return result;
 }
コード例 #37
0
        public HrmpProgram Parse(string filepath)
        {
            HrmpProgram program = null;

            using (StreamReader file = new StreamReader(filepath))
            {
                string lastLabel = null;
                CommandList commandList = new CommandList();

                string line;
                while ((line = file.ReadLine()) != null)
                {
                    ICommand command = ParseLine(line);
                    if (command == null)
                    {
                        // Not a command, check if it is a label for a jump.
                        if (line.EndsWith(":"))
                        {
                            // If there was a previous label, save the current commandList to that ExecutionNode.
                            if (lastLabel != null && program != null)
                            {
                                ExecutionNode en = new ExecutionNode(lastLabel, commandList);
                                program.AddExecutionNode(en);
                            }
                            // Else, create the main ExecutionNode and create the HrmpProgram.
                            else
                            {
                                ExecutionNode en = new ExecutionNode("main", commandList);
                                program = new HrmpProgram(en);
                            }

                            // Clear the current commandList.
                            commandList.Clear();

                            // Save the label for the next ExecutionNode.
                            line = line.Remove(line.Count() - 1);
                            lastLabel = line;
                        }

                        continue;
                    }
                    // Else, it is a command.
                    else
                    {
                        commandList.Add(command);
                    }
                }

                // End of file, so add the current commandList.
                // If there was a previous label, save the current commandList to that ExecutionNode.
                if (lastLabel != null && program != null)
                {
                    ExecutionNode en = new ExecutionNode(lastLabel, commandList);
                    program.AddExecutionNode(en);
                }
                // Else, create the main ExecutionNode and create the HrmpProgram.
                else
                {
                    ExecutionNode en = new ExecutionNode("main", commandList);
                    program = new HrmpProgram(en);
                }

                file.Close();
            }

            return program;
        }
コード例 #38
0
ファイル: CommandCache.cs プロジェクト: TycTak/TycTak
        private CommandList Wrap(IEnumerable<CommandContainer> cmds)
        {
            CommandList wrapper = new CommandList();

            foreach (CommandContainer cmd in cmds) {
                cmd.Processed = DateTime.Now;
                wrapper.Add(cmd);
            }

            return wrapper;
        }