Esempio n. 1
0
        private void AddToken(DatumWriterToken writerToken)
        {
            if (parent != null)
            {
                if (parent.Datum.type == Datum.DatumType.R_OBJECT)
                {
                    parent.Datum.r_object.Add(new Datum.AssocPair()
                    {
                        key = propertyName,
                        val = writerToken.Datum
                    });
                    propertyName = null;
                }
                else
                {
                    parent.Datum.r_array.Add(writerToken.Datum);
                }
                writerToken.Parent = parent;
            }
            else
            {
                if (writerToken.Datum.type != Datum.DatumType.R_OBJECT && writerToken.Datum.type != Datum.DatumType.R_ARRAY)
                {
                    throw new JsonException(
                              string.Format("Error writing {0} value. Datum must start with an Object or Array.", writerToken.Datum.type), null);
                }

                parent = writerToken;
                root   = writerToken;
            }
        }
Esempio n. 2
0
 private void SerializeSingleValue(Datum d)
 {
     //No object start or array start has been called.
     //We are only serializing a single value / datum.
     this.root   = new DatumWriterToken(d);
     this.parent = this.root;
 }
Esempio n. 3
0
 private void RemoveParent()
 {
     parent = parent.Parent;
 }
Esempio n. 4
0
 private void AddParent(DatumWriterToken writerToken)
 {
     AddToken(writerToken);
     this.parent = writerToken;
 }