Ejemplo n.º 1
0
 public void SetCurrentKey <TKey>(TKey key)
 {
     if (curr.CurrentKey is null)
     {
         curr.CurrentKey = RWPathInfo.Create(key);
     }
     else
     {
         RWPathInfo.SetPath(curr.CurrentKey, key);
     }
 }
Ejemplo n.º 2
0
        public IValueWriter this[int key]
        {
            get
            {
                if (typeof(TMode) == typeof(JsonSerializeModes.ReferenceMode))
                {
                    Reference = RWPathInfo.Create(key, Reference.Parent);
                }

                return(this);
            }
        }
Ejemplo n.º 3
0
        public IValueWriter this[string key]
        {
            get
            {
                if (typeof(TMode) == typeof(JsonSerializeModes.ReferenceMode))
                {
                    Reference = RWPathInfo.Create(key, Reference.Parent);
                }

                AppendKeyBefore();

                InternalWriteString(key);

                AppendKeyAfter();

                return(this);
            }
        }
Ejemplo n.º 4
0
        public void WriteObject(IDataReader <string> dataReader)
        {
            if (typeof(TMode) == typeof(JsonSerializeModes.ReferenceMode))
            {
                if ((Options & (JsonFormatterOptions.MultiReferencingNull | JsonFormatterOptions.LoopReferencingNull)) != 0 &&
                    (Options & JsonFormatterOptions.IgnoreNull) != 0 && !Reference.IsRoot)
                {
                }
                else if (!CheckObjectReference(dataReader))
                {
                    return;
                }
            }

            WriteValueBefore();

            Expand(2);

            Append(FixObject);

            AppendStructBefore();

            var isInArray = false;

            if (typeof(TMode) != typeof(JsonSerializeModes.SimpleMode))
            {
                isInArray = IsInArray;

                IsInArray = false;
            }

            int tOffset = offset;

            if (AddDepth())
            {
                if (typeof(TMode) == typeof(JsonSerializeModes.SimpleMode))
                {
                    dataReader.OnReadAll(this);
                }
                else
                {
                    if (typeof(TMode) == typeof(JsonSerializeModes.ReferenceMode))
                    {
                        if (dataReader.Count != 0)
                        {
                            dataReader.OnReadAll(References);
                        }

                        Reference = RWPathInfo.Create(string.Empty, Reference);
                    }

                    if (Options >= JsonFormatterOptions.IgnoreNull)
                    {
                        dataReader.OnReadAll(this, this);
                    }
                    else
                    {
                        dataReader.OnReadAll(this);
                    }

                    if (typeof(TMode) == typeof(JsonSerializeModes.ReferenceMode))
                    {
                        Reference = Reference.Parent;
                    }
                }
            }

            SubtractDepth();

            Expand(2);

            if (tOffset != offset)
            {
                --offset;
            }

            AppendStructAfter();

            Append(ObjectEnding);

            if (typeof(TMode) != typeof(JsonSerializeModes.SimpleMode))
            {
                IsInArray = isInArray;
            }

            AppendValueAfter();
        }