Пример #1
0
        internal override void ReadAttributes(XmlReaderDelegator xmlReader)
#endif
        {
            if (attributes == null)
            {
                attributes = new Attributes();
            }
            attributes.Reset();

            if (xmlReader.MoveToAttribute(JsonGlobals.typeString) && xmlReader.Value == JsonGlobals.nullString)
            {
                attributes.XsiNil = true;
            }
            else if (xmlReader.MoveToAttribute(JsonGlobals.serverTypeString))
            {
                XmlQualifiedName qualifiedTypeName = JsonReaderDelegator.ParseQualifiedName(xmlReader.Value);
                attributes.XsiTypeName = qualifiedTypeName.Name;

                string serverTypeNamespace = qualifiedTypeName.Namespace;

                if (!string.IsNullOrEmpty(serverTypeNamespace))
                {
                    switch (serverTypeNamespace[0])
                    {
                    case '#':
                        serverTypeNamespace = string.Concat(Globals.DataContractXsdBaseNamespace, serverTypeNamespace.Substring(1));
                        break;

                    case '\\':
                        if (serverTypeNamespace.Length >= 2)
                        {
                            switch (serverTypeNamespace[1])
                            {
                            case '#':
                            case '\\':
                                serverTypeNamespace = serverTypeNamespace.Substring(1);
                                break;

                            default:
                                break;
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }

                attributes.XsiTypeNamespace = serverTypeNamespace;
            }
            xmlReader.MoveToElement();
        }
        internal override void ReadAttributes(XmlReaderDelegator xmlReader)
        {
            if (base.attributes == null)
            {
                base.attributes = new Attributes();
            }
            base.attributes.Reset();
            if (xmlReader.MoveToAttribute("type") && (xmlReader.Value == "null"))
            {
                base.attributes.XsiNil = true;
            }
            else if (xmlReader.MoveToAttribute("__type"))
            {
                XmlQualifiedName name = JsonReaderDelegator.ParseQualifiedName(xmlReader.Value);
                base.attributes.XsiTypeName = name.Name;
                string str = name.Namespace;
                if (!string.IsNullOrEmpty(str))
                {
                    switch (str[0])
                    {
                    case '#':
                        str = "http://schemas.datacontract.org/2004/07/" + str.Substring(1);
                        break;

                    case '\\':
                        if (str.Length >= 2)
                        {
                            switch (str[1])
                            {
                            case '#':
                            case '\\':
                                str = str.Substring(1);
                                break;
                            }
                        }
                        break;
                    }
                }
                base.attributes.XsiTypeNamespace = str;
            }
            xmlReader.MoveToElement();
        }
Пример #3
0
 protected static bool TryReadNullAtTopLevel(XmlReaderDelegator reader)
 {
     while (reader.MoveToAttribute("type") && (reader.Value == "null"))
     {
         reader.Skip();
         reader.MoveToElement();
         return(true);
     }
     reader.MoveToElement();
     return(false);
 }
Пример #4
0
        protected static bool TryReadNullAtTopLevel(XmlReaderDelegator reader)
        {
            if (reader.MoveToAttribute(JsonGlobals.typeString) && (reader.Value == JsonGlobals.nullString))
            {
                reader.Skip();
                reader.MoveToElement();
                return(true);
            }

            reader.MoveToElement();
            return(false);
        }
 internal static bool TryGetJsonLocalName(XmlReaderDelegator xmlReader, out string name)
 {
     if (xmlReader.IsStartElement(JsonGlobals.itemDictionaryString, JsonGlobals.itemDictionaryString))
     {
         if (xmlReader.MoveToAttribute(JsonGlobals.itemString))
         {
             name = xmlReader.Value;
             return(true);
         }
     }
     name = null;
     return(false);
 }
 internal static bool TryGetJsonLocalName(XmlReaderDelegator xmlReader, out string name)
 {
     if (xmlReader.IsStartElement(JsonGlobals.itemDictionaryString, JsonGlobals.itemDictionaryString))
     {
         if (xmlReader.MoveToAttribute(JsonGlobals.itemString))
         {
             name = xmlReader.Value;
             return true;
         }
     }
     name = null;
     return false;
 }
        internal override void ReadAttributes(XmlReaderDelegator xmlReader)
#endif
        {
            if (attributes == null)
                attributes = new Attributes();
            attributes.Reset();

            if (xmlReader.MoveToAttribute(JsonGlobals.typeString) && xmlReader.Value == JsonGlobals.nullString)
            {
                attributes.XsiNil = true;
            }
            else if (xmlReader.MoveToAttribute(JsonGlobals.serverTypeString))
            {
                XmlQualifiedName qualifiedTypeName = JsonReaderDelegator.ParseQualifiedName(xmlReader.Value);
                attributes.XsiTypeName = qualifiedTypeName.Name;

                string serverTypeNamespace = qualifiedTypeName.Namespace;

                if (!string.IsNullOrEmpty(serverTypeNamespace))
                {
                    switch (serverTypeNamespace[0])
                    {
                        case '#':
                            serverTypeNamespace = string.Concat(Globals.DataContractXsdBaseNamespace, serverTypeNamespace.Substring(1));
                            break;
                        case '\\':
                            if (serverTypeNamespace.Length >= 2)
                            {
                                switch (serverTypeNamespace[1])
                                {
                                    case '#':
                                    case '\\':
                                        serverTypeNamespace = serverTypeNamespace.Substring(1);
                                        break;
                                    default:
                                        break;
                                }
                            }
                            break;
                        default:
                            break;
                    }
                }

                attributes.XsiTypeNamespace = serverTypeNamespace;
            }
            xmlReader.MoveToElement();
        }