/// <summary> /// This should return DataConnection since every query element represents exactly one connection /// In special cases (SPList, Soap) we defer to a subclass to mine more data. /// </summary> /// <param name="queryElement"></param> /// <returns></returns> private static DataConnection ParseDataConnection(XElement queryElement) { XElement dataConnection = queryElement.Element(xsfNamespace + spListConnection); if (dataConnection != null) return SPListConnection.Parse(dataConnection); else if ((dataConnection = queryElement.Element(xsfNamespace + spListConnectionRW)) != null) return SPListConnection.Parse(dataConnection); else if ((dataConnection = queryElement.Element(xsfNamespace + soapConnection)) != null) return SoapConnection.Parse(dataConnection); else if ((dataConnection = queryElement.Element(xsfNamespace + xmlConnection)) != null) return XmlConnection.Parse(dataConnection); else if ((dataConnection = queryElement.Element(xsfNamespace + adoConnection)) != null) return AdoConnection.Parse(dataConnection); // else just grab the type and log that. Nothing else to do here. foreach (XElement x in queryElement.Elements()) { if (dataConnection != null) throw new ArgumentException("More than one adapter found under a query node"); dataConnection = x; } if (dataConnection == null) throw new ArgumentException("No adapter found under query node"); DataConnection dc = new DataConnection(); dc.ConnectionType = dataConnection.Name.LocalName; return dc; }
public static XmlConnection Parse(XElement dataConnection) { XmlConnection xc = null; bool isRest = IsConnectionRest(dataConnection); xc = isRest ? new RESTConnection() : new XmlConnection(); xc.Url = dataConnection.Attribute(fileUrlAttribute).Value; return xc; }
public static DataConnection Parse(XElement dataConnection) { XmlConnection xc = null; bool isRest = IsConnectionRest(dataConnection); xc = isRest ? new RESTConnection() : new XmlConnection(); string fileUrl = dataConnection.Attribute(fileUrlAttribute).Value; if (!String.IsNullOrEmpty(fileUrl)) { // We have an embedded XmlConnection xc.Url = dataConnection.Attribute(fileUrlAttribute).Value; return(xc); } else { // The XmlConnection is stored in a UDCX connection file XElement udcExtension = FindChild(dataConnection); return(UdcConnection.Parse(dataConnection, udcExtension)); } }