예제 #1
0
        public ScriptLineView CreateLineView(string scriptLineText, int lineIndex, bool @default = false)
        {
            var lineType = Script.ResolveLineType(scriptLineText);
            var lineView = default(ScriptLineView);

            switch (lineType.Name)
            {
            case nameof(CommentScriptLine):
                var commentScriptLine = new CommentScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = new CommentLineView(commentScriptLine, linesContainer);
                break;

            case nameof(LabelScriptLine):
                var labelScriptLine = new LabelScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = new LabelLineView(labelScriptLine, linesContainer);
                break;

            case nameof(DefineScriptLine):
                var defineScriptLine = new DefineScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = new DefineLineView(defineScriptLine, linesContainer);
                break;

            case nameof(CommandScriptLine):
                var commandScriptLine = new CommandScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = CommandLineView.CreateOrError(commandScriptLine, linesContainer, config.HideUnusedParameters, @default);
                break;

            case nameof(GenericTextScriptLine):
                var genericTextScriptLine = new GenericTextScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = new GenericTextLineView(genericTextScriptLine, linesContainer);
                break;
            }
            return(lineView);
        }
예제 #2
0
        /// <summary>
        /// Attempts to extract all command lines text from provided line text.
        /// In cases when the line is <see cref="GenericTextScriptLine"/>, all the inlined command's text will be added.
        /// </summary>
        private static List <string> ExtractActionsFromLine(string lineText)
        {
            var result   = new List <string>();
            var lineType = Script.ResolveLineType(lineText);

            if (lineType == typeof(CommandScriptLine))
            {
                result.Add(lineText);
            }
            if (lineType == typeof(GenericTextScriptLine))
            {
                result.AddRange(new GenericTextScriptLine(null, 0, lineText).InlinedCommandLines.Select(a => a.Text));
            }
            return(result);
        }
예제 #3
0
        public ScriptLineView CreateLineView(int lineIndex, string lineText)
        {
            var lineView = default(ScriptLineView);

            switch (Script.ResolveLineType(lineText?.TrimFull()).Name)
            {
            case nameof(CommentScriptLine):
                lineView = new CommentLineView(lineIndex, lineText, linesContainer);
                break;

            case nameof(LabelScriptLine):
                lineView = new LabelLineView(lineIndex, lineText, linesContainer);
                break;

            case nameof(CommandScriptLine):
                lineView = CommandLineView.CreateOrError(lineIndex, lineText, linesContainer, config.HideUnusedParameters);
                break;

            case nameof(GenericTextScriptLine):
                lineView = new GenericTextLineView(lineIndex, lineText, linesContainer);
                break;
            }
            return(lineView);
        }