// 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.ComponentModel;
[ToolboxBitmap ("bitmap file goes here")]
public class ObjectDataSource : DataSourceControl
{
+ static readonly string [] emptyNames = new string [] { "DefaultView" };
ObjectDataSourceView defaultView;
+
+ int cacheDuration = 0;
+ bool enableCaching = false;
+ string cacheKeyDependency = null;
+ string sqlCacheDependency = null;
+ DataSourceCacheManager cache = null;
+ DataSourceCacheExpiry cacheExpirationPolicy = DataSourceCacheExpiry.Absolute;
public ObjectDataSource ()
{
ObjectDataSourceView DefaultView {
get {
- if (defaultView == null)
- defaultView = new ObjectDataSourceView (this, "DefaultView", Context);
+ if (defaultView == null) {
+ defaultView = new ObjectDataSourceView (this, emptyNames [0], Context);
+ if (IsTrackingViewState)
+ ((IStateManager) defaultView).TrackViewState ();
+ }
return defaultView;
}
}
}
[DefaultValue (0)]
- [TypeConverter ("System.Web.UI.DataSourceCacheDurationConverter, " + Consts.AssemblySystem_Web)]
- [MonoTODO]
+ [TypeConverter (typeof (DataSourceCacheDurationConverter))]
public virtual int CacheDuration
{
get {
- throw new NotImplementedException ();
+ return cacheDuration;
}
set {
- throw new NotImplementedException ();
+ if (value < 0)
+ throw new ArgumentOutOfRangeException ("value", "The duration must be non-negative");
+
+ cacheDuration = value;
}
}
[DefaultValue (DataSourceCacheExpiry.Absolute)]
- [MonoTODO]
public virtual DataSourceCacheExpiry CacheExpirationPolicy
{
get {
- throw new NotImplementedException ();
+ return cacheExpirationPolicy;
}
set {
- throw new NotImplementedException ();
+ cacheExpirationPolicy = value;
}
}
[DefaultValue ("")]
- [MonoTODO]
public virtual string CacheKeyDependency
{
get {
- throw new NotImplementedException ();
+ return cacheKeyDependency != null ? cacheKeyDependency : string.Empty;
}
set {
- throw new NotImplementedException ();
+ cacheKeyDependency = value;
}
}
-
-
[WebCategoryAttribute ("Data")]
[DefaultValueAttribute (ConflictOptions.OverwriteChanges)]
public ConflictOptions ConflictDetection {
}
[DefaultValue (false)]
- [MonoTODO]
public bool ConvertNullToDBNull
{
get {
- throw new NotImplementedException ();
+ return DefaultView.ConvertNullToDBNull;
}
set {
- throw new NotImplementedException ();
+ DefaultView.ConvertNullToDBNull = value;
}
}
-
[WebCategoryAttribute ("Data")]
[DefaultValueAttribute ("")]
public string DataObjectTypeName {
}
[DefaultValue (false)]
- [MonoTODO]
- public virtual bool EnableCaching
- {
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
+ public virtual bool EnableCaching {
+ get { return enableCaching; }
+ set { enableCaching = value; }
}
-
[WebCategoryAttribute ("Paging")]
[DefaultValueAttribute (false)]
public bool EnablePaging {
set { DefaultView.SortParameterName = value; }
}
+ [MonoTODO ("SQLServer specific")]
[DefaultValue ("")]
- [MonoTODO]
- public virtual string SqlCacheDependency
- {
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
+ public virtual string SqlCacheDependency {
+ get { return sqlCacheDependency != null ? sqlCacheDependency : string.Empty; }
+ set { sqlCacheDependency = value; }
}
-
[WebCategoryAttribute ("Paging")]
[DefaultValueAttribute ("startRowIndex")]
public string StartRowIndexParameterName {
public ParameterCollection UpdateParameters {
get { return DefaultView.UpdateParameters; }
}
-
+
+ internal DataSourceCacheManager Cache {
+ get {
+ if (cache == null)
+ cache = new DataSourceCacheManager (CacheDuration, CacheKeyDependency, CacheExpirationPolicy, this, Context);
+ return cache;
+ }
+ }
+
protected override DataSourceView GetView (string viewName)
{
+ if (viewName == null)
+ throw new ArgumentException ("viewName");
+
return DefaultView;
}
protected override ICollection GetViewNames ()
{
- return new string [] { "DefaultView" };
+ return emptyNames;
}
public IEnumerable Select ()
void OnPageLoadComplete (object sender, EventArgs e)
{
- DeleteParameters.UpdateValues (Context, this);
FilterParameters.UpdateValues (Context, this);
- InsertParameters.UpdateValues (Context, this);
SelectParameters.UpdateValues (Context, this);
- UpdateParameters.UpdateValues (Context, this);
}
protected override void LoadViewState (object savedState)
}
}
}
-#endif
+