Ejemplo n.º 1
0
        internal override Object GetSimpleValueInElement(L3TypeManager typeManager)
        {
            if (!GetNextXmlPart())
            {
                throw new Exception();
            }

            if (this.xmlReader.NodeType == XmlNodeType.EndElement)
            {
#if DEBUG
                if (typeManager.l2TypeManager.L1TypeManager.type != typeof(string))
                {
                    throw new Exception();
                }
#endif
                return(DeserializationFormatter.NoValue);
            }

#if DEBUG
            if (this.xmlReader.NodeType != XmlNodeType.Text)
            {
                throw new Exception();
            }
#endif
            var rawValue = this.xmlReader.Value;
            return(DeserializationFormatter.TranscodeStringToPrimitiveObject(rawValue, typeManager));
        }
Ejemplo n.º 2
0
        // ------------------------------

        internal override Object GetSimpleValueInElement(L3TypeManager typeManager)
        {
            if (!GetNextJSONPart())
            {
                throw new Exception();
            }
            if (this._JSONReader.NodeType == XmlNodeType.EndElement)
            {             // empty 'e' element.
                this.WeAlreadyObtainedJSONPart = true;
                return(null);
            }
#if DEBUG
            if (this._JSONReader.NodeType != XmlNodeType.Element || this._JSONReader.Name != "a:item")
            {
                throw new Exception();
            }
#endif

            {
                if (!GetNextJSONPart())
                {
                    throw new Exception();
                }
#if DEBUG
                if (this._JSONReader.NodeType != XmlNodeType.Text || this._JSONReader.Name != string.Empty)
                {
                    throw new Exception();
                }
#endif
            }

            string rawValue;
            {
                // JsonReaderWriterFactory is very special: it splits string when it encounters a special character.
                // Therfore, we need to concatenate this parts.

                var Texts = new StringBuilder(this._JSONReader.Value);
                while (GetNextJSONPart())
                {
                    if (this._JSONReader.NodeType != XmlNodeType.Text)
                    {
                        this.WeAlreadyObtainedJSONPart = true;
                        break;
                    }
                    Texts.Append(this._JSONReader.Value);
                }
                rawValue = Texts.ToString();
            }

            {             // passes EndElement:
                if (!GetNextJSONPart())
                {
                    throw new Exception();
                }
#if DEBUG
                if (this._JSONReader.NodeType != XmlNodeType.EndElement || this._JSONReader.Name != "a:item")
                {
                    throw new Exception();
                }
#endif
            }

            return(DeserializationFormatter.TranscodeStringToPrimitiveObject(rawValue, typeManager));
        }