public override async void Action(string commandLineText, params object[] args)
        {
            CyberConsole cc    = (args[0] as CyberConsole);
            int          start = cc.Document.LineCount;

            cc.InsertText("Building . . .");
            cc.IsEnabled = false;
            await Task.Run(() =>
            {
                IAttrib[] attribs = (Parser as StandardParser).GetAttributes(this, commandLineText);
                CurrentAttributes = ExtractAttributes(attribs).ToArray();
                SetParameters <StringParameter, string>(commandLineText);
                SetParameters <QuoteStringParameter, string>(commandLineText);
                if (IsCorrectSyntax(true))
                {
                    if (IsCorrectParameters())
                    {
                        if (CurrentAttributes.Length > 1)
                        {
                            Message = new ParametersExcessError("File attribute must have a single path to .cs file.").Message;
                            return;
                        }
                        else if (CurrentAttributes.Length == 0)
                        {
                            CurrentAttributes = new IAttrib[] { new FileAttribute() }
                        }
                        ;
                        (CurrentAttributes[0] as FileAddAttribute).Action(
                            Parameters.OfType <StringParameter>().Select(p => p.Value).ToArray(),                //Get files.
                            Parameters.FirstOrDefault(p => p.GetType() == typeof(QuoteStringParameter))?.Value); //Get name.
                        Message = CurrentAttributes[0].Message;
                    }
                    else
                    {
                        Message = "Module should contain only one name.";
                    }
                }
                else
                {
                    Message = GetErrorMessage(commandLineText);
                }
                cc.InsertTextAsync(Message, start);
            });
        }
Exemple #2
0
        public override void Action(string commandLineText, params object[] args)
        {
            CyberConsole cc = args[0] as CyberConsole;

            commandLineText = commandLineText.Replace(" ", "");
            if (IsCorrectSyntax() && cc != null && commandLineText.Length == Spelling.Length)
            {
                cc.Text = string.Empty;
                (cc.TextArea.LeftMargins[0] as NewLineMargin).Clear();
                (cc.TextArea.ReadOnlySectionProvider as TextSegmentReadOnlySectionProvider <TextSegment>).Segments.Clear();
            }
            else if (cc == null)
            {
                Message = new NullArgumentError("CyberConsole").Message;
            }
            else if (commandLineText.Length != Spelling.Length)
            {
                Message = new ParametersExcessError("This command shouldn't have any arguments.").Message;
            }
            else
            {
                Message = new SyntaxError().Message;
            }
        }