// Sanjay Gupta (gsanjay@novell.com)
//
// (C) 2003 Ben Maurer
-// (C) 2004 Novell, Inc. (http://www.novell.com)
+// (C) 2004-2010 Novell, Inc. (http://www.novell.com)
//
//
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
using System.Collections;
using System.Collections.Specialized;
using System.Text;
namespace System.Web.UI {
public abstract class DataSourceView
{
- IDataSource dataSourceOwner;
+ //IDataSource dataSourceOwner;
string viewName = String.Empty;
- [MonoTODO ("Extra method to keep things compiling")]
- protected DataSourceView()
- {
- }
-
- protected DataSourceView(IDataSource owner, string viewName)
+ protected DataSourceView (IDataSource owner, string viewName)
{
- this.dataSourceOwner = owner;
+ if (owner == null)
+ throw new ArgumentNullException ("owner");
+
+ //this.dataSourceOwner = owner;
this.viewName = viewName;
+ owner.DataSourceChanged += new EventHandler (OnDataSourceChanged);
+ }
+
+ void OnDataSourceChanged (object sender, EventArgs e) {
+ OnDataSourceViewChanged (EventArgs.Empty);
}
public virtual void Delete (IDictionary keys, IDictionary values,
if (callBack == null)
throw new ArgumentNullException ("callBack");
- int rowAffected = 0;
- Exception passOn = null;
+ int rowAffected;
try {
rowAffected = ExecuteDelete (keys, values);
- } catch (Exception e) {
- passOn = e;
}
-
- callBack (rowAffected, passOn);
+ catch (Exception e) {
+ if (!callBack (0, e))
+ throw;
+ return;
+ }
+ callBack (rowAffected, null);
}
protected virtual int ExecuteDelete(IDictionary keys, IDictionary values)
if (callBack == null)
throw new ArgumentNullException("callBack");
- int rowAffected = 0;
- Exception passOn = null;
+ int rowAffected;
try {
rowAffected = ExecuteInsert (values);
} catch (Exception e) {
- passOn = e;
+ if (!callBack (0, e))
+ throw;
+ return;
}
- callBack (rowAffected, passOn);
+ callBack (rowAffected, null);
}
protected virtual void OnDataSourceViewChanged (EventArgs eventArgs)
{
- EventHandler evtHandler = eventsList [EventDataSourceViewChanged] as EventHandler;
- if (evtHandler != null)
- evtHandler(this, eventArgs);
+ if (eventsList != null) {
+ EventHandler evtHandler = eventsList [EventDataSourceViewChanged] as EventHandler;
+ if (evtHandler != null)
+ evtHandler(this, eventArgs);
+ }
}
protected internal virtual void RaiseUnsupportedCapabilityError (
DataSourceCapabilities capability)
{
- if (capability == DataSourceCapabilities.Sort)
+ if ((capability & DataSourceCapabilities.Sort) != 0)
if (!CanSort)
throw new NotSupportedException ("Sort Capabilites");
- if (capability == DataSourceCapabilities.Page)
+ if ((capability & DataSourceCapabilities.Page) != 0)
if (!CanPage)
throw new NotSupportedException("Page Capabilites");
- if (capability == DataSourceCapabilities.RetrieveTotalRowCount)
+ if ((capability & DataSourceCapabilities.RetrieveTotalRowCount) != 0)
if (!CanRetrieveTotalRowCount)
throw new NotSupportedException("RetrieveTotalRowCount Capabilites");
-
- if (capability == (DataSourceCapabilities.Sort &
- DataSourceCapabilities.Page))
- if (!(CanSort && CanPage))
- throw new NotSupportedException ("Sort Capabilites");
-
- if (capability == (DataSourceCapabilities.Sort &
- DataSourceCapabilities.RetrieveTotalRowCount))
- if (!(CanSort && CanRetrieveTotalRowCount))
- throw new NotSupportedException("Page Capabilites");
-
- if (capability == (DataSourceCapabilities.Page &
- DataSourceCapabilities.RetrieveTotalRowCount))
- if (!(CanPage && CanRetrieveTotalRowCount))
- throw new NotSupportedException("RetrieveTotalRowCount Capabilites");
-
- if (capability == (DataSourceCapabilities.Sort &
- DataSourceCapabilities.Page &
- DataSourceCapabilities.RetrieveTotalRowCount))
- if (!(CanSort && CanPage && CanRetrieveTotalRowCount))
- throw new NotSupportedException ("Sort Capabilites");
return;
}
- [MonoTODO ("Extra method to keep things compiling, need to remove later")]
- public abstract IEnumerable Select ();
-
public virtual void Select (DataSourceSelectArguments selectArgs,
DataSourceViewSelectCallback callBack)
{
callBack (selectList);
}
- public virtual int Update(IDictionary keys, IDictionary values,
+ public virtual void Update(IDictionary keys, IDictionary values,
IDictionary oldValues, DataSourceViewOperationCallback callBack)
{
if (callBack == null)
throw new ArgumentNullException ("callBack");
- int rowAffected = 0;
- Exception passOn = null;
+ int rowAffected;
try {
rowAffected = ExecuteUpdate (keys, values, oldValues);
} catch (Exception e) {
- passOn = e;
+ if (!callBack (0, e))
+ throw;
+ return;
}
- callBack (rowAffected, passOn);
- return rowAffected;
+ callBack (rowAffected, null);
}
public virtual bool CanDelete { get { return false; } }
return eventsList != null;
}
- public virtual string Name {
+ public string Name {
get { return viewName; }
}
}
}
-#endif