JsonWriter.Init C# (CSharp) Method

Init() private method

private Init ( ) : void
return void
        private void Init ()
        {
            has_reached_end = false;
            hex_seq = new char[4];
            indentation = 0;
            indent_value = 4;
            pretty_print = false;
            validate = true;

            ctx_stack = new Stack<WriterContext> ();
            context = new WriterContext ();
            ctx_stack.Push (context);
        }

Usage Example

Example #1
0
    public void Serialize(Stream serializationStream, object graph)
    {
        if (serializationStream == null)
        {
            throw new System.ArgumentNullException("serializationStream");
        }
        if (graph == null)
        {
            throw new System.ArgumentNullException("graph");
        }

        if (_writer == null)
        {
            _writer = new JsonWriter();
        }

        var writer = new StreamWriter(serializationStream);

        try
        {
            _writer.Init(writer);

            this.WriteObject(graph);
        }
        catch (SerializationException ex)
        {
            throw ex;
        }
        catch (System.Exception ex)
        {
            throw new SerializationException("Object graph is malformed.", ex);
        }
        finally
        {
            writer.Flush();
            _writer.Clear();
        }
    }