DynamicDataSource.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.DynamicData;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. namespace MonoTests.DataSource
  10. {
  11. [PersistChildren(false)]
  12. [ParseChildren(true)]
  13. public class DynamicDataSource : DataSourceControl, IDynamicDataSource
  14. {
  15. const string DEFAULT_VIEW_NAME = "DefaultView";
  16. static readonly string[] emptyNames = new string[] { "DefaultView" };
  17. DynamicDataSourceView defaultView;
  18. ParameterCollection whereCollection;
  19. public DynamicDataSourceView DefaultView
  20. {
  21. get
  22. {
  23. if (defaultView == null)
  24. defaultView = new DynamicDataSourceView (this, DEFAULT_VIEW_NAME);
  25. return defaultView;
  26. }
  27. }
  28. public string DataContainerTypeName
  29. {
  30. get;
  31. set;
  32. }
  33. public object DataContainerInstance
  34. {
  35. get;
  36. set;
  37. }
  38. #region DataSourceControl Members
  39. protected override DataSourceView GetView (string viewName)
  40. {
  41. if (String.IsNullOrEmpty (viewName))
  42. return DefaultView;
  43. return new DynamicDataSourceView (this, viewName);
  44. }
  45. #endregion
  46. #region IDynamicDataSource Members
  47. public bool AutoGenerateWhereClause
  48. {
  49. get;
  50. set;
  51. }
  52. public Type ContextType
  53. {
  54. get;
  55. set;
  56. }
  57. public bool EnableDelete
  58. {
  59. get;
  60. set;
  61. }
  62. public bool EnableInsert
  63. {
  64. get;
  65. set;
  66. }
  67. public bool EnableUpdate
  68. {
  69. get;
  70. set;
  71. }
  72. public string EntitySetName
  73. {
  74. get;
  75. set;
  76. }
  77. public event EventHandler<DynamicValidatorEventArgs> Exception;
  78. public string Where
  79. {
  80. get;
  81. set;
  82. }
  83. [PersistenceMode (PersistenceMode.InnerProperty)]
  84. public ParameterCollection WhereParameters
  85. {
  86. get {
  87. if (whereCollection == null)
  88. whereCollection = new ParameterCollection ();
  89. return whereCollection;
  90. }
  91. }
  92. #endregion
  93. #region IDataSource Members
  94. DataSourceView IDataSource.GetView (string viewName)
  95. {
  96. return GetView (viewName);
  97. }
  98. ICollection IDataSource.GetViewNames ()
  99. {
  100. return emptyNames;
  101. }
  102. #endregion
  103. }
  104. }