Ejemplo n.º 1
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);
                }
            }
        }
Ejemplo n.º 2
0
        public static ScriptCommandList FromText(string text)
        {
            var result = new ScriptCommandList();

            result.Add(text);
            result.OriginalText = text;

            return(result);
        }
Ejemplo n.º 3
0
        public static RoomieScript FromFile(string path)
        {
            var result = new RoomieScript
            {
                Source   = path,
                Commands = ScriptCommandList.FromFile(path)
            };

            return(result);
        }
Ejemplo n.º 4
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);
        }