merge -r 53370:58178
[mono.git] / mcs / class / System.Web / System.Web.UI / DataSourceSelectArguments.cs
1 //
2 // System.Web.UI.DataSourceSelectArguments.cs
3 //
4 // Author:
5 //   Sanjay Gupta <gsanjay@novell.com>
6 //
7 // (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32 using System;
33
34 namespace System.Web.UI
35 {
36         public sealed class DataSourceSelectArguments
37         {
38                 string sortExpression = string.Empty;
39                 int startingRowIndex = 0;
40                 int maxRows = 0;
41                 bool getTotalRowCount = false;
42                 int totalRowCount = -1;
43                 DataSourceCapabilities dsc = DataSourceCapabilities.None;
44
45                 static DataSourceSelectArguments empty = new DataSourceSelectArguments();
46                 public static DataSourceSelectArguments Empty {
47                         get {
48                                 return empty;
49                         }
50                 }
51
52                 public DataSourceSelectArguments ()
53                 {
54                 }
55
56                 public DataSourceSelectArguments (string sortExpression)
57                 {
58                         this.sortExpression = sortExpression;
59                 }
60
61                 public DataSourceSelectArguments (int startingRowIndex, int maxRows)
62                 {
63                         this.startingRowIndex = startingRowIndex;
64                         this.maxRows = maxRows;
65                 }
66
67                 public DataSourceSelectArguments (string sortExpression, int startingRowIndex, int maxRows)
68                 {
69                         this.sortExpression = sortExpression; 
70                         this.startingRowIndex = startingRowIndex;
71                         this.maxRows = maxRows;
72                 }
73
74                 public void AddSupportedCapabilities (DataSourceCapabilities srcCapabilities)
75                 {
76                         this.dsc = this.dsc | srcCapabilities;
77                 }
78
79                 public override bool Equals (object obj)
80                 {
81                         if (!(obj is DataSourceSelectArguments))
82                                 return false;
83
84                         DataSourceSelectArguments args = (DataSourceSelectArguments)obj;
85                         return (this.sortExpression == args.sortExpression &&
86                                 this.startingRowIndex == args.startingRowIndex &&
87                                 this.maxRows == args.maxRows);
88                 }
89
90                 [MonoTODO]
91                 public override int GetHashCode ()
92                 {
93                         return sortExpression.GetHashCode ();
94                 }
95
96                 public void RaiseUnsupportedCapabilitiesError (DataSourceView view)
97                 {
98                         view.RaiseUnsupportedCapabilityError (this.dsc);
99                 }
100
101                 public int MaximumRows {
102                         get { return this.maxRows; }
103                         set {
104                                 this.maxRows = value;
105                         }
106                 }
107
108                 public bool RetrieveTotalRowCount  {
109                         get { return this.getTotalRowCount; }
110                         set { this.getTotalRowCount = value; }
111                 }
112
113                 public string SortExpression {
114                         get { return this.sortExpression; }
115                         set {
116                                 this.sortExpression = value;
117                         }
118                 }
119
120                 public int StartRowIndex {
121                         get { return this.startingRowIndex; }
122                         set {
123                                 this.startingRowIndex = value;
124                         }
125                 }
126
127                 public int TotalRowCount {
128                         get { return this.totalRowCount; }
129                         set {
130                                 this.totalRowCount = value;
131                         }
132                 }
133         }
134 }
135 #endif