/// <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;
		}
Ejemplo n.º 2
0
        public static AdoConnection Parse(XElement dataConnection)
        {
            AdoConnection ac = new AdoConnection();

            ac.ConnectionString = dataConnection.Attribute(connectionStringAttribute).Value;
            return(ac);
        }