private static object TryParseIfMethodResponse(XmlDataProvider xmlDataProvider, XElement element) { if (element.Name.LocalName != "methodResponse") { return(null); } dynamic methodResponse = new XmlRpcObject(); var resultOk = (element.Element("params")) != null; if (resultOk) { methodResponse.Result = true; methodResponse.Params = new List <dynamic>(); foreach (var param in element.Element("params").Elements("param")) { var i = (xmlDataProvider.Parse(param.Element("value"))); methodResponse.Params.Add(i); } return(methodResponse); } var isFault = (element.Element("fault")) != null; if (isFault) { methodResponse.Result = false; methodResponse.fault = xmlDataProvider.Parse(element.Element("fault").FirstNode as XElement); return(methodResponse); } return(null); }
public object Parse(XmlDataProvider xmlDataProvider, XElement element) { if (element.Name.LocalName != "value" || (element.FirstNode as XElement)?.Name.LocalName != "struct") { return(null); } if (element.HasElements) { var model = new XmlRpcObject(); var elements = element.Element("struct").Elements("member"); foreach (var elem in elements) { var name = elem.Element("name").Value; model[name] = xmlDataProvider.Parse(elem.Element("value")); } return(model); } return(null); }