/// <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; }
/// <summary> /// Self-explanatory /// </summary> /// <param name="dataConnection"></param> /// <returns></returns> public static SPListConnection Parse(XElement dataConnection) { SPListConnection spl = new SPListConnection(); spl.IsV2 = dataConnection.Name.LocalName.Equals("sharepointListAdapterRW"); if (spl.IsV2) { spl.SiteUrl = dataConnection.Attribute(siteURLAttribute).Value; spl.ListGuid = dataConnection.Attribute(listGuidAttribute).Value; spl.SubmitAllowed = dataConnection.Attribute(submitAllowedAttribute).Value; spl.RelativeListUrl = dataConnection.Attribute(relativeListUrlAttribute).Value; // we should also scrape out the queried column types, this shows us what types of data we consume from lists foreach (XElement fieldElement in dataConnection.Elements(xsfNamespace + field)) { string fieldType = fieldElement.Attribute(typeAttribute).Value; spl._bucketCounter.IncrementKey(fieldType); } } else // if (dataConnection.Name.LocalName.Equals("sharepointListAdapter")) { spl.SiteUrl = dataConnection.Attribute(siteUrlAttribute).Value; spl.ListGuid = dataConnection.Attribute(sharepointGuidAttribute).Value; spl.SubmitAllowed = dataConnection.Attribute(submitAllowedAttribute).Value; } return spl; }