Beispiel #1
0
        private AtomContentProperty ReadPropertyValue()
        {
            Debug.Assert(this.reader != null, "reader != null");
            Debug.Assert(
                this.reader.NodeType == XmlNodeType.Element,
                "reader.NodeType == XmlNodeType.Element -- otherwise caller is confused as to where the reader is");

            if (!this.IsDataWebElement)
            {
                SkipToEndAtDepth(this.reader, this.reader.Depth);
                return(null);
            }

            AtomContentProperty result = new AtomContentProperty();

            result.Name     = this.reader.LocalName;
            result.TypeName = this.reader.GetAttributeEx(XmlConstants.AtomTypeAttributeName, XmlConstants.DataWebMetadataNamespace);
            result.IsNull   = Util.DoesNullAttributeSayTrue(this.reader);
            result.Text     = result.IsNull ? null : String.Empty;

            if (!this.reader.IsEmptyElement)
            {
                int depth = this.reader.Depth;
                while (this.reader.Read())
                {
                    this.ReadPropertyValueIntoResult(result);
                    if (this.reader.Depth == depth)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Beispiel #2
0
        internal static string ReadElementString(XmlReader reader, bool checkNullAttribute)
        {
            Debug.Assert(reader != null, "reader != null");
            Debug.Assert(
                reader.NodeType == XmlNodeType.Element,
                "reader.NodeType == XmlNodeType.Element -- otherwise caller is confused as to where the reader is");

            string result = null;
            bool   empty  = checkNullAttribute && !Util.DoesNullAttributeSayTrue(reader);

            if (reader.IsEmptyElement)
            {
                return(empty ? String.Empty : null);
            }

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.EndElement:
                    return(result ?? (empty ? String.Empty : null));

                case XmlNodeType.CDATA:
                case XmlNodeType.Text:
                case XmlNodeType.SignificantWhitespace:
                    if (null != result)
                    {
                        throw Error.InvalidOperation(Strings.Deserialize_MixedTextWithComment);
                    }

                    result = reader.Value;
                    break;

                case XmlNodeType.Comment:
                case XmlNodeType.Whitespace:
                    break;

                    #region XmlNodeType error
                case XmlNodeType.Element:
                    goto default;

                default:
                    throw Error.InvalidOperation(Strings.Deserialize_ExpectingSimpleValue);
                    #endregion
                }
            }

            // xml ended before EndElement?
            throw Error.InvalidOperation(Strings.Deserialize_ExpectingSimpleValue);
        }
Beispiel #3
0
        internal static string ReadElementString(XmlReader reader, bool checkNullAttribute)
        {
            // This item is obfuscated and can not be translated.
            bool   expressionStack_11_0;
            string str = null;

            if (checkNullAttribute)
            {
                expressionStack_11_0 = !Util.DoesNullAttributeSayTrue(reader);
            }
            else
            {
                expressionStack_11_0 = false;
            }
            bool flag = expressionStack_11_0;

            if (reader.IsEmptyElement)
            {
                if (!flag)
                {
                    return(null);
                }
                return(string.Empty);
            }
Label_0091:
            if (!reader.Read())
            {
                throw System.Data.Services.Client.Error.InvalidOperation(System.Data.Services.Client.Strings.Deserialize_ExpectingSimpleValue);
            }
            switch (reader.NodeType)
            {
            case XmlNodeType.Text:
            case XmlNodeType.CDATA:
            case XmlNodeType.SignificantWhitespace:
                if (str != null)
                {
                    throw System.Data.Services.Client.Error.InvalidOperation(System.Data.Services.Client.Strings.Deserialize_MixedTextWithComment);
                }
                str = reader.Value;
                goto Label_0091;

            case XmlNodeType.Comment:
            case XmlNodeType.Whitespace:
                goto Label_0091;

            case XmlNodeType.EndElement:
                string expressionStack_63_0;
                if (str != null)
                {
                    return(str);
                }
                else
                {
                    expressionStack_63_0 = str;
                }
                expressionStack_63_0 = string.Empty;
                if (flag)
                {
                    return(string.Empty);
                }
                return(null);
            }
            throw System.Data.Services.Client.Error.InvalidOperation(System.Data.Services.Client.Strings.Deserialize_ExpectingSimpleValue);
        }