Esempio n. 1
0
 ///<summary>Registers all commands defined in the class T.</summary>
 ///<typeparam name="T">The class where the commands are stored.</typeparam>
 ///<remarks>The class holding the commands cannot be static.
 ///Commands must have a return type of Task/ValueTask and cannot be static.
 ///The first parameter must be a <c>Context</c>.</remarks>
 public static void RegisterCommands <T>() where T : class
 {
     CommandsInstance = Activator.CreateInstance(typeof(T));
     MethodInfo[] methods = typeof(T).GetMethods();
     foreach (MethodInfo m in methods)
     {
         if (!m.IsDefined(typeof(CommandAttribute)))
         {
             return;
         }
         if (m.ReturnType.GetMethod(nameof(Task.GetAwaiter)) == null)
         {
             throw new InvalidSignatureException("The return type of the method must derive from Task or ValueTask to be a command.", m.Name);
         }
         if (m.IsStatic)
         {
             throw new InvalidSignatureException("A static method cannot be a command.", m.Name);
         }
         if (!typeof(Context).IsAssignableFrom(m.GetParameters()[0].ParameterType))
         {
             throw new InvalidSignatureException("The first argument of a command must be a Context.", m.Name);
         }
         if (m.IsDefined(typeof(AliasesAttribute)))
         {
             CommandsList.Add(new Command(m.GetCustomAttribute <CommandAttribute>().Name, m, m.GetCustomAttribute <AliasesAttribute>().Aliases));
         }
         else
         {
             CommandsList.Add(new Command(m.GetCustomAttribute <CommandAttribute>().Name, m, new List <string>()));
         }
     }
 }
Esempio n. 2
0
        public CommandHandlerBase(CommandHandlerOptions options)
        {
            Options  = options;
            Commands = new CommandsList();

            RegisterTypeParsers();
        }
        public void Setup()
        {
            _commands = new CommandsList();

            _fakeCommand = A.Fake <IBotCommand>();
            A.CallTo(() => _fakeCommand.CommandName).Returns("someCommand");
        }
    // Update is called once per frame
    void Update()
    {
        bool rightPressed = Input.GetKey(TurnRightKey);
        bool leftPressed  = Input.GetKey(TurnLeftKey);
        bool accPressed   = Input.GetKey(AccelerateKey);
        bool breakPressed = Input.GetKey(BreakKey);

        if (rightPressed && !leftPressed)
        {
            //CommandsList.Add(new Turn(TurnDirection.Right));
            CommandsList.Add(new SimplifiedCommand(CommandType.TurnRight));
        }

        if (leftPressed && !rightPressed)
        {
            //CommandsList.Add(new Turn(TurnDirection.Left));
            CommandsList.Add(new SimplifiedCommand(CommandType.TurnLeft));
        }

        if (accPressed && !breakPressed)
        {
            //CommandsList.Add(new Accelerate());
            CommandsList.Add(new SimplifiedCommand(CommandType.Accelerate));
        }

        if (!accPressed && breakPressed)
        {
            //CommandsList.Add(new Break());
            CommandsList.Add(new SimplifiedCommand(CommandType.Break));
        }
    }
    public void GiveAllControls()
    {
        _directionalControls = GetComponents <DirectionalControl>().ToList();
        List <Controls> allControls = GetComponents <Controls>().ToList();

        CommandsList.RegisterAction(() => CommandsList.Instance.InitCommandsList(allControls));
    }
Esempio n. 6
0
        private void ReadAndProcessProcPacket(IAsyncResult R)
        {
            Connection conn = (Connection)R.AsyncState;

            while (!R.IsCompleted)
            {
                ;
            }
            conn.Soc.EndReceive(R);
            UInt16 ExecCode = BitConverter.ToUInt16(conn.buffer, 0);

            if (CommandsList.VerifyCommandExists(ExecCode))
            {
                Int64  ArgsSize  = BitConverter.ToInt64(conn.buffer, 2);
                string AsciiArgs = "";
                if (ArgsSize > 0)
                {
                    conn.buffer = new byte[ArgsSize];
                    conn.Soc.Receive(conn.buffer);
                    AsciiArgs = Encoding.ASCII.GetString(conn.buffer);
                }

                conn.Soc.Send(BitConverter.GetBytes(ServerCodes.Success));
                ReturnStream RS = new ReturnStream(conn.Soc);
                CommandsList.Execute(ExecCode, AsciiArgs, RS);
                RS.Close();
            }
            else
            {
                conn.Soc.Send(BitConverter.GetBytes(ServerCodes.InvalidCommandCode));
            }
        }
Esempio n. 7
0
        public override void Selected(GUI.Selection selection)
        {
            bool promptQuit = false;

            GUI.ListBox listBox = selection.RowIndex switch
            {
                0 => BackedUpLevelsList,
                1 => BackedUpScriptsList,
                _ => throw new NotImplementedException(),
            };
            CommandsList.HighlightCurrentItem();
            listBox.Clear();
            listBox.Draw();
            listBox.NavigateToDefault();
            while (!promptQuit)
            {
                var subSelection = BackedUpLevelsList.PromptSelection();
                if (subSelection.Command == Properties.Command.Cancel)
                {
                    promptQuit = true;
                }
            }

            CommandsList.SelectCurrentItem();
            DetailsTextBox.Clear();
            WriteSummary();
        }
Esempio n. 8
0
        public Commands(string Menu, string Name, int Col, int Row)
        {
            menu  = Menu;
            name  = Name;
            idTag = new Point(Col, Row);
            if (Col > MaxIdTag.Col)
            {
                MaxIdTag = new Point(Col, MaxIdTag.Row);
            }
            if (Row > MaxIdTag.Row)
            {
                MaxIdTag = new Point(MaxIdTag.Col, Row);
            }
            CommandsList.Add(this);

            ////if ((Row == Commands.ElementConfigInt[cSensorsRowIndexKey]) && (Col != Commands.ElementConfigInt[cCommandActionsColIndexKey]))
            ////{
            ////    Array.Resize(ref Sensors, Sensors.Length + 1);
            ////    Sensors[Sensors.Length - 1] = Name;
            ////}
            ////else if (Col == Commands.ElementConfigInt[cCommandActionsColIndexKey])
            ////{
            ////    Array.Resize(ref CommandActions, CommandActions.Length + 1);
            ////    CommandActions[CommandActions.Length - 1] = Name.Substring(1);
            ////}
        }
Esempio n. 9
0
 public static void LoadHooks()
 {
     CommandsList.CreateCommand(CommandsList.CreateID(), new Action <CommandArgs>(ChangeLeds), "ChangeLeds", "Ev3DevBotController.LoadHooks (ChangeLEDS)");
     CommandsList.CreateCommand(CommandsList.CreateID(), new Action <CommandArgs>(PrintDevices), "PrintDevices", "Ev3DevBotController.LoadHooks (PrintDevices)");
     CommandsList.CreateCommand(CommandsList.CreateID(), new Action <CommandArgs>(Cmd), "Cmd", "Ev3DevBotController.LoadHooks (Cmd)");
     CommandsList.CreateCommand(CommandsList.CreateID(), new Action <CommandArgs>(BotExecute), "BotExecute", "Ev3DevBotController.LoadHooks (BotExecute)");
     CommandsList.CreateCommand(CommandsList.CreateID(), new Action <CommandArgs>(UpdatePorts), "UpdatePorts", "Ev3DevBotController.LoadHooks (UpdatePorts)");
 }
Esempio n. 10
0
        private ICommand[] Mutate(ICommand[] commands)
        {
            var commandsList = new CommandsList(commands);
            var mutator      = new Mutator.Mutator(new Random(), commandsList);

            mutator.Mutate();
            return(commandsList.ToArray());
        }
Esempio n. 11
0
        public Main(params string[] args)
        {
            InitializeComponent();

            Commands = new CommandsList();

            explorer     = new ExplorerTool(this);
            commander    = new CommanderTool(this);
            output       = new OutputTool(this);
            propertyGrid = new PropertyGridTool(this);

            var hierarchyProvider = Config.GetProvider(args);

            Hierarchy = hierarchyProvider.CreateHierarchy(this);
            var startingNode = Hierarchy.Nodes().FirstOrDefault();

            Hierarchy.ActivationRequested += (ars, ara) =>
            {
                var window = DockPanel.GetOpenDocumentWindows().Where(x => x.Node.Equals(ara)).FirstOrDefault();
                if (window != null)
                {
                    window.Activate();
                }
                else
                {
                    var editor = ara.GetEditor(typeof(Control));
                    if (editor != null)
                    {
                        var newWindow = new DocumentWindowBase(this, ara);
                        newWindow.Show(this.DockPanel, DockState.Document);
                        newWindow.Controls.Add(editor as Control);
                        editor.ActivateIn(newWindow);
                    }
                }
            };


            commander.Show(DockPanel, DockState.DockLeft);
            explorer.Show(DockPanel, DockState.DockLeft);
            propertyGrid.Show(DockPanel, DockState.DockRight);
            output.Show(DockPanel, DockState.DockBottom);

            if (startingNode != null)
            {
                startingNode.Select();
                Hierarchy.Activate(startingNode);
            }


            //Commands.Add("Show Output", () => { output.Show(this.DockPanel, DockState.DockBottom); }, "Show the output panel");
            //  Commands.Add("Show Explorer", () => { explorer.Show(this.DockPanel, DockState.DockLeft); }, "Show the explorer panel");
            // Commands.Add("Show Properties", () => { propertyGrid.Show(this.DockPanel, DockState.DockRight); }, "Show the selected object properties panel");

            //       RegisterQuickieText();

            SetupKeyHook();
            GoFullscreen(false);
        }
Esempio n. 12
0
 public SaveManagerWindow() : base(Text.SaveManagerWindowTitle, MenuColor.SaveMangerWindowTitleBG, MenuColor.SaveMangerWindowTitleFG)
 {
     CommandsList = Menu.AddListBox(0, null, true);
     CommandsList.SetItems(new string[] {
         Text.BackUpCurrentSave,
         Text.ViewBackups,
         Text.ToggleAutoBackups
     });
     DetailsTextBox      = Menu.AddTextBox(1, null);
     BackedUpSavesList   = new GUI.ListBox(DetailsTextBox.Left, DetailsTextBox.Top, DetailsTextBox.Width, DetailsTextBox.Height, MenuColor.ContentBG, MenuColor.ContentFG, true);
     currentSavedMapName = string.Empty;
     backedUpSaves       = new List <string>();
 }
Esempio n. 13
0
        private void HandleMouseDown(CanvasData canvasData, Point clickCoordinates)
        {
            InputMode inputMode = InputMode.SingleLeftClick;

            if ((ModifierKeys == Keys.Control))
            {
                inputMode = InputMode.CtrlPressed;
            }

            canvasData = GetBehaviorAndCanvasData(canvasData, clickCoordinates, inputMode);
            CommandsList.GetCommand(canvasData).Change(canvasData);
            this.canvasData = canvasData;
        }
Esempio n. 14
0
    public static PacketType ClientDeserialize(List <Snapshot> interpolationBuffer, PlayerJoined playerJoined, BitBuffer buffer,
                                               int displaySeq, CommandsList clientCommands, int cmdSeq, List <Shot> shots, int shotSeq,
                                               ShotBroadcast shotBroadcast, out int commandSnapshotAck, out int playerDisconnect)
    {
        commandSnapshotAck = -1;
        var messageType = buffer.GetByte();

        playerDisconnect = -1;
        if (messageType == (byte)PacketType.UPDATE_MESSAGE)
        {
            ClientDeserializeUpdate(interpolationBuffer, buffer, displaySeq, clientCommands, out commandSnapshotAck);
            return(PacketType.UPDATE_MESSAGE);
        }
        if (messageType == (byte)PacketType.PLAYER_JOINED)
        {
            PlayerJoinedDeserialize(playerJoined, buffer);
            return(PacketType.PLAYER_JOINED);
        }
        if (messageType == (byte)PacketType.COMMANDS_ACK_MESSAGE)
        {
            int receivedAckSequence = ClientDeserializeAck(buffer);
            clientCommands.Ack(receivedAckSequence);
            return(PacketType.COMMANDS_ACK_MESSAGE);
        }
        if (messageType == (byte)PacketType.SHOT_ACK)
        {
            int receivedShotAckSeq = ClientDeserializeShotAck(buffer);
            int count = 0;
            foreach (var shot in shots)
            {
                if (shot.Seq <= receivedShotAckSeq)
                {
                    count++;
                }
            }
            shots.RemoveRange(0, count);
            return(PacketType.SHOT_ACK);
        }

        if (messageType == (byte)PacketType.SHOT_BROADCAST)
        {
            DeserializeShotBroadcast(buffer, shotBroadcast);
            return(PacketType.SHOT_BROADCAST);
        }

        if (messageType == (byte)PacketType.PLAYER_DISCONNECT)
        {
            playerDisconnect = PlayerDisconnectDeserialize(buffer);
        }
        return(PacketType.PLAYER_DISCONNECT);
    }
Esempio n. 15
0
        private void HandleMouseMove(CanvasData canvasData, Point clickCoordinates)
        {
            if (canvasData.behaviourMode == BehaviourMode.VertexMove)
            {
                canvasData.clickCoordinates = clickCoordinates;
                CommandsList.GetCommand(canvasData).Change(canvasData);
            }
            else if (canvasData.behaviourMode == BehaviourMode.PolygonMove)
            {
                canvasData.moveCoordinates = clickCoordinates;
                CommandsList.GetCommand(canvasData).Change(canvasData);
            }

            this.canvasData = canvasData;
        }
Esempio n. 16
0
        /// <summary>
        /// Load Autoexec options value from dictionary
        /// </summary>
        /// <param name="dictionary">Dictionary with options DosBox data</param>
        public override void LoadDictionary(IDictionary <string, object> dictionary)
        {
            foreach (var data in dictionary)
            {
                switch (data.Key)
                {
                case "content":
                    Commands = new CommandsList(data.Value.ToString());
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 17
0
    private static void ClientDeserializeUpdate(List <Snapshot> interpolationBuffer, BitBuffer buffer,
                                                int displaySeq, CommandsList clientCommands, out int commandSnapshotAck)
    {
        commandSnapshotAck = -1;
        var seq         = buffer.GetInt();
        var time        = buffer.GetFloat();
        var cmdSeq      = buffer.GetInt();
        var playerCount = buffer.GetInt();

        Dictionary <int, UserState> userStates = new Dictionary <int, UserState>();
        int i;

        for (i = 0; i < playerCount; i++)
        {
            var position = new Vector3();
            var rotation = new Quaternion();

            var userID = buffer.GetInt();
            position.x = buffer.GetFloat();
            position.y = buffer.GetFloat();
            position.z = buffer.GetFloat();
            rotation.w = buffer.GetFloat();
            rotation.x = buffer.GetFloat();
            rotation.y = buffer.GetFloat();
            rotation.z = buffer.GetFloat();

            userStates.Add(userID, new UserState(position, rotation));
        }

        if (seq < displaySeq)
        {
            return;
        }

        clientCommands.SnapshotAck(cmdSeq);
        commandSnapshotAck = cmdSeq;

        Snapshot snapshot = new Snapshot(seq, time, cmdSeq, userStates);

        for (i = 0; i < interpolationBuffer.Count; i++)
        {
            if (interpolationBuffer[i].Seq > seq)
            {
                break;
            }
        }
        interpolationBuffer.Insert(i, snapshot);
    }
Esempio n. 18
0
    public static void ClientSerializeInput(CommandsList clientCommands, BitBuffer buffer)
    {
        buffer.PutByte((byte)PacketType.COMMANDS);
        var unackedCommands = clientCommands.GetUnackedCommands();

        buffer.PutInt(unackedCommands.Count);
        foreach (Commands commands in unackedCommands)
        {
            buffer.PutInt(commands.Seq);
            buffer.PutInt(commands.UserID);
            buffer.PutInt(commands.Up ? 1 : 0);
            buffer.PutInt(commands.Down ? 1 : 0);
            buffer.PutInt(commands.Left ? 1 : 0);
            buffer.PutInt(commands.Right ? 1 : 0);
            buffer.PutInt(commands.Space ? 1 : 0);
            buffer.PutFloat(commands.Rotation);
        }
    }
Esempio n. 19
0
        public Task AddCommandModuleAsync <T>() where T : new()
        {
            var type = typeof(T);

            CommandsList.AddRange(type.GetMethods().Where(x => x.HasAttribute <CommandAttribute>() && x.IsPublic).Select(x => new Command()
            {
                ClassInstance     = new T(),
                Method            = x,
                MethodParams      = x.GetParameters(),
                CommandName       = x.GetCustomAttribute <CommandAttribute>().CommandName,
                Aliases           = x.GetCustomAttribute <AliasesAttribute>()?.Aliases,
                ParentCommandName = null
            } as Command?));

            var groups = typeof(T).GetNestedTypes().Where(x => x.IsPublic && (x.HasAttribute <GroupAttribute>())) as IReadOnlyList <Type>;

            for (var count = 0; count < groups?.Count(); count++)
            {
                var submths = groups[count].GetMethods().Where(x => x.IsPublic && (x.GetCustomAttribute <CommandAttribute>() != null)) as IReadOnlyList <MethodInfo>;
                var subcmds = new List <Command>();
                for (var i = 0; i < submths.Count(); i++)
                {
                    subcmds.Add(new Command()
                    {
                        ClassInstance     = groups[count],
                        Method            = CommandsList[i].Value.Method,
                        Aliases           = CommandsList[i].Value.Method.GetCustomAttribute <AliasesAttribute>()?.Aliases,
                        CommandName       = CommandsList[i].Value.Method.GetCustomAttribute <CommandAttribute>().CommandName,
                        ParentCommandName = groups[count].GetCustomAttribute <GroupAttribute>().GroupName
                    });
                }

                GroupCommandsList.Add(new CommandGroup()
                {
                    GroupName     = groups[count].GetCustomAttribute <GroupAttribute>().GroupName,
                    Aliases       = groups[count].GetCustomAttribute <AliasesAttribute>().Aliases,
                    SubCommands   = subcmds,
                    ExecuteMethod = subcmds.FirstOrDefault(x => x.Method.Name == "ExecuteGroupAsync").Method
                });
            }

            return(Task.CompletedTask);
        }
Esempio n. 20
0
 public BackupsWindow() : base(Text.BackupsWindowTitle, MenuColor.BackupsWindowTitleBG, MenuColor.BackupsWindowTitleFG)
 {
     CommandsList = Menu.AddListBox(0, null, true);
     CommandsList.SetItems(new string[] {
         Text.BackedUpLevels,
         Text.BackedUpScripts,
     });
     DetailsTextBox     = Menu.AddTextBox(1, null);
     BackedUpLevelsList = new GUI.ListBox(
         DetailsTextBox.Left, DetailsTextBox.Top,
         DetailsTextBox.Width, DetailsTextBox.Height,
         MenuColor.ContentBG, MenuColor.ContentFG,
         true);
     BackedUpScriptsList = new GUI.ListBox(
         DetailsTextBox.Left, DetailsTextBox.Top,
         DetailsTextBox.Width, DetailsTextBox.Height,
         MenuColor.ContentBG, MenuColor.ContentFG,
         true);
 }
Esempio n. 21
0
        private void addCommand(CommandsList commandList)
        {
            StackPanel commandPane = new StackPanel();

            commandPane.Margin = new Thickness(0, 3, 0, 3);
            foreach (Command command in commandList.Commands)
            {
                Button commandBtn = new Button()
                {
                    Content         = command.Name,
                    Name            = command.Code,
                    BorderThickness = new Thickness(0),
                    Foreground      = new SolidColorBrush(Colors.Black),
                    Background      = new SolidColorBrush(Colors.LightGray)
                };
                commandBtn.Click += new RoutedEventHandler(Button_Clicked);
                commandPane.Children.Add(commandBtn);
            }
            ContentPanel.Children.Add(commandPane);
        }
Esempio n. 22
0
        public CommandController(Message message, TelegramBotClient botClient)
        {
            Commands = new List <Command>();
            var commands = new CommandsList();

            foreach (var command in commands.GetCommands())
            {
                IsContains(command);
            }
            Save <Command>(Commands);

            foreach (var command in Load <Command>())
            {
                if (command.Contains(message.Text))
                {
                    command.Execute(message, botClient);

                    return;
                }
            }
        }
Esempio n. 23
0
        private void CommandText_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            var count = CommandsList.ItemContainerGenerator.Items.Count;

            if (count == 0)
            {
                return;
            }
            var delta = 0;

            if (e.Key == Key.Up)
            {
                delta = -1; e.Handled = true;
            }
            if (e.Key == Key.Down)
            {
                delta = 1; e.Handled = true;
            }
            CommandsList.SelectedIndex = (CommandsList.SelectedIndex + delta + count) % count;
            CommandsList.ScrollIntoView(CommandsList.SelectedItem);
        }
Esempio n. 24
0
        static void Main()
        {
            var sentryKey = AppConfig.GetConfiguration("external:sentry:key");
            var sentryId  = AppConfig.GetConfiguration("external:sentry:id");

            var hostUri = AppConfig.GetConfiguration("server:host_uri") ?? "http://*****:*****@sentry.io/{sentryId}")) {
                var host = new NancyHost(new Bootstrapper(), new Uri(hostUri));

                AppBoot.Boot();

                Console.WriteLine("Server version: " + Assembly.GetExecutingAssembly().GetName().Version);
                Console.WriteLine("Starting server");
                Console.WriteLine("Starting server...");
                host.Start();
                Console.WriteLine("Server started");

                Cli.CliLoop(CommandsList.Get());
            }
        }
Esempio n. 25
0
        public override void Selected(GUI.Selection selection)
        {
            if (selection.List.IsEmpty)
            {
                return;
            }
            LogTextBox.ClearContent();

            switch (selection.RowIndex)
            {
            case 0:                     // Backup current map
                LogTextBox.WriteLine(Text.BackingUpCurrentSave);
                BackupCurrentSave();
                RefreshInfo();
                WriteSummary();
                LogTextBox.WriteLine(string.Format(Text.BackedUpMap, currentSavedMapName));
                break;

            case 1:                     // View backups...
                CommandsList.HighlightCurrentItem();
                ShowBackups();
                CommandsList.SelectCurrentItem();
                break;

            case 2:
                if (Program.manageSaves)
                {
                    Program.manageSaves = false;
                    LogTextBox.WriteLine(Text.DisabledManageSaves);
                }
                else
                {
                    Program.manageSaves = true;
                    LogTextBox.WriteLine(Text.EnabledManageSaves);
                }
                Program.SaveSettings();
                WriteSummary();
                break;
            }
        }
        /// <summary>
        /// Processes the specified solution path.
        /// </summary>
        /// <param name="projectsViewModel">The projects view model.</param>
        /// <param name="applicationOptionsViewModel">The application options view model.</param>
        /// <param name="ninjaCoderOptionsViewModel">The ninja coder options view model.</param>
        /// <param name="applicationSamplesOptionsViewModel">The application samples options view model.</param>
        /// <param name="viewsViewModel">The views view model.</param>
        /// <param name="pluginsViewModel">The plugins view model.</param>
        /// <param name="nugetPackagesViewModel">The nuget packages view model.</param>
        /// <param name="xamarinFormsLabsViewModel">The xamarin forms labs view model.</param>
        internal void Process(
            ProjectsViewModel projectsViewModel,
            ApplicationOptionsViewModel applicationOptionsViewModel,
            NinjaCoderOptionsViewModel ninjaCoderOptionsViewModel,
            ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel,
            ViewsViewModel viewsViewModel,
            PluginsViewModel pluginsViewModel,
            NugetPackagesViewModel nugetPackagesViewModel,
            XamarinFormsLabsViewModel xamarinFormsLabsViewModel)
        {
            TraceService.WriteLine("ProjectsController::Process");

            foreach (SelectableItemViewModel <ProjectTemplateInfo> projectTemplateInfo in projectsViewModel.Projects)
            {
                TraceService.WriteLine(projectTemplateInfo.Item.Name + " project selected=" + projectTemplateInfo.IsSelected);
            }

            this.VisualStudioService.WriteStatusBarMessage(NinjaMessages.NinjaIsRunning);

            this.applicationService.SuspendResharperIfRequested();

            this.projectsService.IsNewSolution = this.VisualStudioService.SolutionAlreadyCreated;

            //// create the solution if we don't have one!
            if (this.projectsService.IsNewSolution == false)
            {
                this.VisualStudioService.SolutionService.CreateEmptySolution(projectsViewModel.GetSolutionPath(), projectsViewModel.Project);
            }

            if (this.SettingsService.CreateTestProjectsSolutionFolder)
            {
                this.VisualStudioService.SolutionService.AddSolutionFolder(this.SettingsService.TestProjectsSolutionFolderName);
                this.VisualStudioService.DTEService.SaveAll();
            }

            this.messages = this.projectsService.AddProjects(
                this.VisualStudioService,
                projectsViewModel.GetSolutionPath(),
                projectsViewModel.GetFormattedRequiredTemplates())
                            .ToList();

            this.projectsService.SetStartUpProject();

            //// there is a bug in the xamarin iOS code that means it doesnt apply a couple of xml elements
            //// in the info.plist - here we fix that issue.

            if (this.SettingsService.FixInfoPlist)
            {
                this.applicationService.FixInfoPList(projectsViewModel.GetFormattedRequiredTemplates()
                                                     .FirstOrDefault(x => x.ProjectSuffix == this.SettingsService.iOSProjectSuffix));
            }

            IEnumerable <string> viewNugetCommands = new List <string>();

            if (this.SettingsService.FrameworkType != FrameworkType.NoFramework &&
                viewsViewModel != null)
            {
                //// if we dont have a viewmodel and view in memory - add one
                //// user will have dont show views and viewmodel options selected.
                if (!viewsViewModel.Views.Any())
                {
                    viewsViewModel.Add();
                }

                IEnumerable <string> viewModelMessages = this.viewModelViewsService.AddViewModelsAndViews(viewsViewModel.Views);

                this.messages.AddRange(viewModelMessages);

                viewNugetCommands = this.viewModelViewsService.GetNugetCommands();
            }

            TraceService.WriteLine("ProjectsController::Process GetApplication Commands");

            //// we need to get the post nuget commands that are now hosted in xml file that used to be in code
            CommandsList commandsList = this.applicationService.GetCommandsList();

            if (commandsList != null)
            {
                this.postNugetCommands.AddRange(commandsList.Commands);
                this.postNugetFileOperations.AddRange(commandsList.FileOperations);
            }

            IEnumerable <ProjectTemplateInfo> projectTemplateInfos = projectsViewModel.GetFormattedRequiredTemplates();

            this.commands += this.nugetService.GetNugetCommands(projectTemplateInfos);

            if (viewNugetCommands.Any())
            {
                foreach (string viewNugetCommand in viewNugetCommands)
                {
                    this.commands += viewNugetCommand + Environment.NewLine;
                }
            }

            this.PopulateNugetActions(applicationOptionsViewModel);
            this.PopulateNugetActions(ninjaCoderOptionsViewModel);
            this.PopulateNugetActions(applicationSamplesOptionsViewModel);
            this.PopulateNugetActions(pluginsViewModel);
            this.PopulateNugetActions(nugetPackagesViewModel);
            this.PopulateNugetActions(xamarinFormsLabsViewModel);

            this.cachingService.PostNugetCommands       = this.postNugetCommands;
            this.cachingService.PostNugetFileOperations = this.postNugetFileOperations;

            //// a bit of (unnecessary) tidying up - replace double new lines!
            this.commands = this.commands.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine);

            this.CreateReadMe(false, false);

            TraceService.WriteHeader("RequestedNugetCommands=" + this.commands);

            if (this.SettingsService.ProcessNugetCommands)
            {
                this.ProcessNugetCommands();
            }

            TraceService.WriteLine("ProjectsController::Process END");
        }
        public Result deserialize(String json)
        {
            if (json == null || json.Equals(""))
            {
                return(null);
            }
            Result result = new Result();

            try
            {
                JObject jObject = JObject.Parse(json);
                result.Cookie     = (String)jObject["cookie"];
                result.Title      = (String)jObject["title"];
                result.HideCancel = (Boolean)jObject["hideCancel"];
                result.ShowBack   = (Boolean)jObject["showBack"];
                JArray jArray = (JArray)jObject["resultParts"];

                foreach (JObject obj in jArray)
                {
                    int type = (int)obj["type"];
                    switch (type)
                    {
                    case 0:
                        result.ResultParts.Add((String)obj["message"]);
                        break;

                    case 1:
                        ResultList resultList = new ResultList();
                        resultList.MultiSelectionEnable = (Boolean)obj["isMultiSelection"];
                        resultList.Title = (String)obj["title"];
                        JArray records = (JArray)obj["records"];
                        if (records != null)
                        {
                            foreach (JObject jRecord in records)
                            {
                                Record record = new Record();
                                record.Code = (String)jRecord["code"];
                                JArray cells = (JArray)jRecord["cells"];
                                foreach (JObject jCell in cells)
                                {
                                    Cell cell = new Cell();
                                    cell.Title = (String)jCell["title"];
                                    cell.Value = (String)jCell["value"];
                                    record.Cells.Add(cell);
                                }
                                resultList.Records.Add(record);
                            }
                        }
                        result.ResultParts.Add(resultList);
                        break;

                    case 2:
                        CommandsList commandsList = new CommandsList();
                        JArray       jCommands    = (JArray)obj["commandNames"];
                        if (jCommands != null)
                        {
                            foreach (JObject jCommand in jCommands)
                            {
                                Command command = new Command();
                                command.Name = (String)jCommand["name"];
                                command.Code = (String)jCommand["code"];
                                commandsList.Commands.Add(command);
                            }
                        }
                        result.ResultParts.Add(commandsList);
                        break;

                    case 3:
                        InputType inputType = new InputType();
                        inputType.Type  = (int)obj["inputType"];
                        inputType.Name  = (String)obj["name"];
                        inputType.Value = (String)obj["value"];
                        result.ResultParts.Add(inputType);
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                Console.Write(exception.StackTrace);
            }

            return(result);
        }
Esempio n. 28
0
 public FreeWill(CommandsList commandList)
 {
     _commandList = commandList;
     DetermineTakeControlTime();
 }
Esempio n. 29
0
 protected void RunCommands()
 {
     CommandsList.ForEach(command => Proc.StandardInput.WriteLine(command));
     FinishCmd(Proc.StandardInput);
 }
Esempio n. 30
0
 private static Command FindCommand(string name) => CommandsList.Find((Command c) => c.Name == name || c.Aliases.Contains(name)) ?? throw new CommandNotFoundException($"Command not found.", name);