private object GetDataTableValue(object value, IList<IDisposable> disposeList)
 {
     IEnumerable values = value as IEnumerable;
     if (values == null) {
         throw new ArgumentException(string.Format("The value passed in for parameter '{0}' is castable to IEnumerable", parameterName));
     }
     StructuredParameterReader dataReader = new StructuredParameterReader(structuredSchema, values);
     disposeList.Add(dataReader);
     return dataReader;
 }
 protected override object SetParameterValue(IMethodCallMessage mcm, IList<IDisposable> disposeList)
 {
     object value = mcm.GetArg(parameterInfo.Position);
     if (value != null) {
         switch (SqlType) {
         case SqlDbType.Xml:
             XmlReader reader = value as XmlReader;
             if (reader == null) {
                 XPathNavigator navigator = value as XPathNavigator;
                 if (navigator == null) {
                     IXPathNavigable navigable = value as IXPathNavigable;
                     if (navigable != null) {
                         navigator = navigable.CreateNavigator();
                     } else {
                         XNode node = value as XNode;
                         if (node != null) {
                             navigator = node.CreateNavigator();
                         }
                     }
                     if (navigator == null) {
                         throw new NotSupportedException(String.Format("XML could not be retrieved from value of type {0}.", value.GetType()));
                     }
                 }
                 reader = navigator.ReadSubtree();
                 disposeList.Add(reader);
             }
             value = new SqlXml(reader);
             break;
         case SqlDbType.SmallInt:
             IIdentifiable<short> identifiableShort = value as IIdentifiable<short>;
             if (identifiableShort != null) {
                 value = identifiableShort.Id;
             }
             break;
         case SqlDbType.Int:
             IIdentifiable<int> identifiableInt = value as IIdentifiable<int>;
             if (identifiableInt != null) {
                 value = identifiableInt.Id;
             }
             break;
         case SqlDbType.BigInt:
             IIdentifiable<long> identifiableLong = value as IIdentifiable<long>;
             if (identifiableLong != null) {
                 value = identifiableLong.Id;
             }
             break;
         case SqlDbType.UniqueIdentifier:
             IIdentifiable<Guid> identifiableGuid = value as IIdentifiable<Guid>;
             if (identifiableGuid != null) {
                 value = identifiableGuid.Id;
             }
             break;
             //				case SqlDbType.Udt:
             //					parameter.UdtTypeName = userDefinedTypeName;
             //					break;
         }
     }
     if (SqlType == SqlDbType.Structured) {
         IDataReader dataReader = new StructuredParameterReader(structuredSchema, (IEnumerable)value);
         disposeList.Add(dataReader);
         value = dataReader;
     }
     return value;
 }