/// <summary> /// Returns XMLRPC Struct object /// </summary> /// <param name="reader"></param> /// <returns>XMLRPC Struct object</returns> public XmlRpcStruct ParseStruct(XmlDictionaryReader reader) { MethodFaultResponse faultResponse = new MethodFaultResponse(); XmlRpcStruct xmlRpcStruct = new XmlRpcStruct(); List <StructMember> listMembers = new List <StructMember>(); if (reader.NodeType == XmlNodeType.Element) { if (reader.Name.ToLower() == "struct") { reader.ReadStartElement("struct"); reader.MoveToContent(); while ((reader.NodeType != XmlNodeType.EndElement) && (reader.NodeType != XmlNodeType.None)) { StructMember mem; if (reader.LocalName == "member") { mem = new StructMember(); mem = ParseStructMember(reader); listMembers.Add(mem); } } xmlRpcStruct.Member = listMembers.ToArray(); } } return(xmlRpcStruct); }
/// <summary> /// Read XML document and deserialize into object /// </summary> /// <param name="reader">XML Reader</param> /// <param name="verifyObjectName"></param> /// <returns></returns> public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName) { MethodResponse methodResponse = null; MethodFaultResponse faultResponse = null; bool isFault = false; Param param = new Param(); object value = null; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name.ToLower() == "fault") { faultResponse = new MethodFaultResponse(); isFault = true; } if (isFault == true) { if (reader.Name.ToLower() == "value") { value = ParseValue(reader); XmlRpcStruct xmlRpcStruct = (XmlRpcStruct)value; foreach (StructMember member in xmlRpcStruct.Member) { if (member.Name == "faultCode") { faultResponse.FaultCode = Convert.ToInt16(member.Value); } else if (member.Name == "faultString") { faultResponse.Message = (string)member.Value; } } } } else { if (reader.Name.ToLower() == "params") { methodResponse = new MethodResponse(); methodResponse.ReceiveParams = new List <Param>(); } else if (reader.Name.ToLower() == "value") { value = ParseValue(reader); if (value != null) { param.Value = value; methodResponse.ReceiveParams.Add(param); } } } } } if (isFault) { isFault = false; //return faultResponse; XmlRpcFaultException ex = new XmlRpcFaultException(faultResponse.FaultCode, faultResponse.Message); throw ex; } else { return(methodResponse); } }