Esempio n. 1
0
        private static void WritePrefix(JsonPropertyVisitor visitor)
        {
            Assert.IsNotNull(visitor);

            visitor.StringBuffer.Clear();
            visitor.StringBuffer.Append(' ', JsonPropertyVisitor.Style.Space * visitor.Indent);
            visitor.StringBuffer.Append("{\n");

            visitor.Indent++;
        }
Esempio n. 2
0
        private static void WriteSuffix(JsonPropertyVisitor visitor)
        {
            Debug.Assert(visitor != null);

            visitor.Indent--;

            visitor.StringBuffer.Length -= 2;
            visitor.StringBuffer.Append("\n");
            visitor.StringBuffer.Append(' ', JsonPropertyVisitor.Style.Space * visitor.Indent);
            visitor.StringBuffer.Append("}");
        }
Esempio n. 3
0
        public static string Write <TContainer>(ref TContainer container, JsonPropertyVisitor visitor = null)
            where TContainer : struct, IPropertyContainer
        {
            if (null == visitor)
            {
                visitor = s_DefaultVisitor;
            }

            WritePrefix(visitor);
            PropertyContainer.Visit(ref container, visitor);
            WriteSuffix(visitor);

            return(visitor.ToString());
        }
Esempio n. 4
0
 public static string Serialize <TContainer>(TContainer container, JsonPropertyVisitor visitor = null)
     where TContainer : class, IPropertyContainer
 {
     return(JsonPropertyContainerWriter.Write(container, visitor));
 }