protected static bool TryReadNullAtTopLevel(XmlReaderDelegator reader)
 {
     while (reader.MoveToAttribute("type") && (reader.Value == "null"))
     {
         reader.Skip();
         reader.MoveToElement();
         return true;
     }
     reader.MoveToElement();
     return false;
 }
示例#2
0
        protected static bool TryReadNullAtTopLevel(XmlReaderDelegator reader)
        {
            while (reader.MoveToAttribute(JsonGlobals.typeString) && (reader.Value == JsonGlobals.nullString))
            {
                reader.Skip();
                reader.MoveToElement();
                return true;
            }

            reader.MoveToElement();
            return false;
        }
        internal override void ReadAttributes(XmlReaderDelegator xmlReader)
        {
            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 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;
 }