Exemple #1
0
 public XmlScriptCommand(string fullName, ScriptCommandParameters parameters = null)
 {
     this.FullName = fullName;
     this.Parameters = parameters ?? new ScriptCommandParameters();
     this.InnerCommands = new ScriptCommandList();
     this.OriginalText = "";//TODO: set something?
 }
Exemple #2
0
        public TextScriptCommand(string line)
        {
            if (_lineRegex == null)
            {
                _lineRegex = new Regex(LinePattern);
                _parametersRegex = new Regex(ParametersPattern);
                _parameterRegex = new Regex(ParameterPattern);
            }

            Parameters = new ScriptCommandParameters();
            InnerCommands = new ScriptCommandList();
            OriginalText = line;

            var matches = _lineRegex.Match(line);

            if (!matches.Groups["FullName"].Success)
            {
                throw new RoomieScriptSyntaxErrorException("No command name specified");
            }

            FullName = matches.Groups["FullName"].Value;

            //TODO: make this less awful
            var parametersPart = matches.Groups["Parameters"];
            if (parametersPart.Success && parametersPart.Length > 0)
            {
                foreach (var parameter in ParseParameters(parametersPart.Value))
                {
                    Parameters.Add(parameter);
                }
            }
        }
Exemple #3
0
        public XmlScriptCommand(XmlNode node)
        {
            this.OriginalText = node.OuterXml;

            FullName = node.Name;

            Parameters = new ScriptCommandParameters();

            foreach (XmlAttribute attribute in node.Attributes)
            {
                var parameter = new ScriptCommandParameter(name: attribute.Name, value: attribute.Value);
                Parameters.Add(parameter);
            }

            InnerCommands = ScriptCommandList.FromText(node.InnerXml);
        }