DynamicDataContainer.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. namespace MonoTests.DataSource
  9. {
  10. public abstract class DynamicDataContainer<T> : IDynamicDataContainer<T>
  11. {
  12. T containedTypeInstance;
  13. public string TableName {
  14. get;
  15. set;
  16. }
  17. public T ContainedTypeInstance {
  18. get { return containedTypeInstance; }
  19. set {
  20. if (value == null)
  21. throw new InvalidOperationException ("Null type instance is not allowed.");
  22. containedTypeInstance = value;
  23. }
  24. }
  25. public DynamicDataContainer ()
  26. : this (null)
  27. { }
  28. public DynamicDataContainer (string tableName)
  29. {
  30. TableName = tableName;
  31. ContainedTypeInstance = Activator.CreateInstance<T> ();
  32. }
  33. public virtual Type ContainedType
  34. {
  35. get { return typeof (T); }
  36. }
  37. #region IDynamicDataContainer Members
  38. public abstract int Update (IDictionary keys, IDictionary values, IDictionary oldValues);
  39. public abstract int Insert (IDictionary values);
  40. public abstract int Delete (IDictionary keys, IDictionary oldValues);
  41. public abstract IEnumerable Select (DataSourceSelectArguments args, string where, ParameterCollection whereParams);
  42. public abstract List<DynamicDataTable> GetTables ();
  43. #endregion
  44. }
  45. }