Write() private static method

private static Write ( Stream stream, string value ) : void
stream Stream
value string
return void
Esempio n. 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, "]");
            }
Esempio n. 2
0
 private static void NewLine(Stream stream, int indent)
 {
     Dom.Write(stream, "\n");
     for (int i = 0; i < indent; i++)
     {
         Dom.Write(stream, "  ");
     }
 }
Esempio n. 3
0
            public virtual void Write(Stream stream, int indent)
            {
                // write type name
                string name = GetTypeName(Type);

                Dom.Write(stream, name);
                Dom.Write(stream, " ");
            }
Esempio n. 4
0
File: Dom.cs Progetto: sachgits/Myre
            public void Write(Stream stream, int indent)
            {
                if (id == null && node != null && node.SharedReferenceID != null)
                {
                    id = node.SharedReferenceID;
                }

                if (id != null)
                {
                    Dom.Write(stream, string.Format("#{0}", id.Value));
                }
                else
                {
                    GetNode().Write(stream, indent);
                }
            }
Esempio n. 5
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, "}");
            }
Esempio n. 6
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, "]");
            }
Esempio n. 7
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);
        }
Esempio n. 8
0
 public override void Write(Stream stream, int indent)
 {
     base.Write(stream, indent);
     Dom.Write(stream, string.Format("\"{0}\"", Value));
 }