NewLine() приватный статический Метод

private static NewLine ( Stream stream, int indent ) : void
stream Stream
indent int
Результат void
Пример #1
0
            public override void Write(Stream stream, int indent)
            {
                // write type name
                base.Write(stream, indent);

                // start list
                Dom.Write(stream, "[");
                Dom.NewLine(stream, indent + 1);

                // write children
                for (int i = 0; i < Children.Count; i++)
                {
                    var item = Children[i];
                    item.Write(stream, indent + 1);

                    if (i < Children.Count - 1)
                    {
                        // comma separated
                        Dom.Write(stream, ",");
                        Dom.NewLine(stream, indent + 1);
                    }
                    else
                    {
                        Dom.NewLine(stream, indent);
                    }
                }

                // end list
                Dom.Write(stream, "]");
            }
Пример #2
0
            public override void Write(Stream stream, int indent)
            {
                // write type name
                base.Write(stream, indent);

                // start object
                Dom.Write(stream, "{");
                Dom.NewLine(stream, indent + 1);

                // write fields
                foreach (var item in Children.Select((kvp, i) => new { Key = kvp.Key, Value = kvp.Value, index = i }))
                {
                    // write field name:
                    Dom.Write(stream, item.Key);
                    Dom.Write(stream, ": ");

                    // write value
                    if (item.Value.GetNode() == null)
                    {
                        Dom.Write(stream, "null");
                    }
                    else
                    {
                        item.Value.Write(stream, indent + 1);
                    }

                    if (item.index < Children.Count - 1)
                    {
                        // comma separate
                        Dom.Write(stream, ",");
                        Dom.NewLine(stream, indent + 1);
                    }
                    else
                    {
                        Dom.NewLine(stream, indent);
                    }
                }

                // end object
                Dom.Write(stream, "}");
            }
Пример #3
0
            public override void Write(Stream stream, int indent)
            {
                // write type name
                base.Write(stream, indent);

                // start dictionary
                Dom.Write(stream, "[");
                Dom.NewLine(stream, indent + 1);

                // write children
                foreach (var item in Children.Select((kvp, i) => new { Key = kvp.Key, Value = kvp.Value, index = i }))
                {
                    // write key:
                    item.Key.Write(stream, indent + 1);
                    Dom.Write(stream, ": ");

                    // write value
                    if (item.Value.GetNode() == null)
                    {
                        Dom.Write(stream, "null");
                    }
                    else
                    {
                        item.Value.Write(stream, indent + 1);
                    }

                    if (item.index < Children.Count - 1)
                    {
                        // comma separated
                        Dom.Write(stream, ",");
                        Dom.NewLine(stream, indent + 1);
                    }
                    else
                    {
                        Dom.NewLine(stream, indent);
                    }
                }

                // end dictionary
                Dom.Write(stream, "]");
            }
Пример #4
0
        private void WriteSharedReferences(Stream stream)
        {
            if (sharedReferences.Count == 0)
            {
                return;
            }

            // start dictionary
            Dom.Write(stream, "R[");
            Dom.NewLine(stream, 1);

            // write children
            foreach (var item in sharedReferences.Select((kvp, i) => new { Key = kvp.Key, Value = kvp.Value, index = i }))
            {
                // write key:
                Dom.Write(stream, item.Key.ToString());
                Dom.Write(stream, ": ");

                // write value
                item.Value.Write(stream, 1);

                if (item.index < sharedReferences.Count - 1)
                {
                    // comma separated
                    Dom.Write(stream, ",");
                    Dom.NewLine(stream, 1);
                }
                else
                {
                    Dom.NewLine(stream, 0);
                }
            }

            // end dictionary
            Dom.Write(stream, "]");
            Dom.NewLine(stream, 0);
        }