Beispiel #1
0
        public void WriteKDL(StreamWriter writer, PrintConfig printConfig) // throws IOException
        {
            if (Value == KDLNull.Instance && printConfig.PrintNullProps)
            {
                return;
            }

            PrintUtil.WriteStringQuotedAppropriately(writer, Key, true, printConfig);
            writer.Write('=');
            Value.WriteKDL(writer, printConfig);
        }
Beispiel #2
0
        internal void WriteKDLPretty(StreamWriter writer, int depth, PrintConfig printConfig)
        {
            PrintUtil.WriteStringQuotedAppropriately(writer, Identifier, true, printConfig);
            if (Args.Count > 0 || Props.Count > 0 || Child != null)
            {
                writer.Write(' ');
            }

            for (int i = 0; i < Args.Count; i++)
            {
                var value = Args[i];
                if (value != KDLNull.Instance || printConfig.PrintNullArgs)
                {
                    value.WriteKDL(writer, printConfig);
                    if (i < Args.Count - 1 || Props.Count > 0 || Child != null)
                    {
                        writer.Write(' ');
                    }
                }
            }

            var keys = Props.Keys.ToList();

            for (int i = 0; i < keys.Count; i++)
            {
                var value = Props[keys[i]];
                if (value != KDLNull.Instance || printConfig.PrintNullProps)
                {
                    PrintUtil.WriteStringQuotedAppropriately(writer, keys[i], true, printConfig);
                    writer.Write('=');
                    value.WriteKDL(writer, printConfig);
                    if (i < keys.Count - 1 || Child != null)
                    {
                        writer.Write(' ');
                    }
                }
            }

            if (Child != null)
            {
                if (Child.Nodes.Count > 0 || printConfig.PrintEmptyChildren)
                {
                    writer.Write('{');
                    writer.Write(printConfig.NewLine);
                    Child.WriteKDL(writer, depth + 1, printConfig);
                    for (int i = 0; i < printConfig.Indent * depth; i++)
                    {
                        writer.Write(printConfig.IndentChar);
                    }
                    writer.Write('}');
                }
            }
        }
Beispiel #3
0
 public void WriteKDL(StreamWriter writer, PrintConfig printConfig)
 => PrintUtil.WriteStringQuotedAppropriately(writer, Value, false, printConfig);