Example #1
0
        private void WriteMetaParameterRow(SharpMetaParameterRow row)
        {
            if (string.Compare(row.Key, "package", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                if (_lastPackage == row.Value.ToString())
                {
                    return;
                }

                _lastPackage = row.Value.ToString();
            }

            _writer.WriteLine(row.ToString());
        }
Example #2
0
        private void WriteMetaParameterRow(SharpMetaParameterRow row)
        {
            if (string.Compare(row.Key, "XmlDeclaration", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                return;
            }

            if (string.Compare(row.Key, "package", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                if (_lastPackage == row.Value.ToString())
                {
                    return;
                }

                _lastPackage = row.Value.ToString();
            }

            _writer.WriteProcessingInstruction(row.Key, row.Value.ToString());
        }
Example #3
0
        public bool ParseRowLine(string line, out SharpRow result)
        {
            result = null;
            line   = line.Trim();
            if (string.IsNullOrEmpty(line))
            {
                return(false);
            }

            if (line.StartsWith("#!"))
            {
                var param = new SharpMetaParameterRow(line);
                if (param.Key.ToLower() == "package" && _nodes != null)
                {
                    _nodes.SetCurrentPackage(param.Value.ToString());
                }
                result = param;
                return(true);
            }

            if (line.StartsWith("#"))
            {
                result = new SharpMetaCommentRow {
                    Value = line.Substring(1)
                };
                return(true);
            }

            var metaNode = new SharpMetaNodeRow(line, _lastFullPath);

            if (line.StartsWith("$"))
            {
                var schemaNode = metaNode.CreateNode();

                if (metaNode.Index == -1)
                {
                    _nodes.Add(schemaNode);
                }
                else
                {
                    _nodes.Insert(schemaNode);
                }

                return(false);
            }

            bool isValueNode = metaNode.IsValueNode;

            if (!isValueNode)
            {
                _lastFullPath = metaNode.Path;
            }

            if (_nodes == null)
            {
                result = metaNode;
                return(true);
            }

            var node = _nodes.GetNode(metaNode.Path);

            if (node != null)
            {
                result = metaNode.CreateNodeRow(node);
                return(true);
            }

            node = metaNode.CreateNode();
            _nodes.Add(node);
            result = metaNode.CreateNodeRow(node);
            return(true);
        }