Esempio n. 1
0
        private void WriteElement(StageElement element)
        {
            bool separate = false;

            _json.WriteElementStart();

            foreach (var a in element.Attributes())
            {
                if (separate)
                {
                    _json.WriteSeparator();
                }
                else
                {
                    separate = true;
                }

                _json.WriteAttributeLabel(a);
                _json.WriteValue(a);
            }

            foreach (var item in element.Items())
            {
                if (separate)
                {
                    _json.WriteSeparator();
                }
                else
                {
                    separate = true;
                }

                _json.WriteLabel(item);

                if (item is StageValue)
                {
                    _json.WriteValue((StageValue)item);
                }
                else if (item is StageElement)
                {
                    WriteElement((StageElement)item);
                }
                else if (item is StageList)
                {
                    WriteList((StageList)item);
                }
                else if (item is StageNull)
                {
                    _json.WriteNull((StageNull)item);
                }
            }

            _json.WriteElementEnd();
        }
Esempio n. 2
0
        private void WriteElement(StageElement element)
        {
            bool flag = false;

            this._json.WriteElementStart();
            foreach (StageAttribute stageAttribute in element.Attributes())
            {
                if (!flag)
                {
                    flag = true;
                }
                else
                {
                    this._json.WriteSeparator();
                }
                this._json.WriteAttributeLabel(stageAttribute);
                this._json.WriteValue(stageAttribute);
            }
            foreach (StageItem stageItem in element.Items())
            {
                if (!flag)
                {
                    flag = true;
                }
                else
                {
                    this._json.WriteSeparator();
                }
                this._json.WriteLabel(stageItem);
                if (stageItem is StageValue)
                {
                    this._json.WriteValue((StageValue)stageItem);
                }
                else if (stageItem is StageElement)
                {
                    this.WriteElement((StageElement)stageItem);
                }
                else if (!(stageItem is StageList))
                {
                    if (!(stageItem is StageNull))
                    {
                        continue;
                    }
                    this._json.WriteNull((StageNull)stageItem);
                }
                else
                {
                    this.WriteList((StageList)stageItem);
                }
            }
            this._json.WriteElementEnd();
        }