[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / System.Web / System.Web.UI / ListSourceHelper.cs
blob84f3d957433675af253a4507fdab416fb6bc058a
1 //
2 // System.Web.UI.ListSourceHelper
3 //
4 // Authors:
5 // Ben Maurer (bmaurer@users.sourceforge.net)
6 //
7 // (C) 2003 Ben Maurer
8 //
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.
31 using System.Collections;
32 using System.Collections.Specialized;
33 using System.Text;
34 using System.ComponentModel;
35 using System.Collections.Generic;
37 namespace System.Web.UI {
38 public static class ListSourceHelper {
40 public static bool ContainsListCollection (IDataSource dataSource)
42 return dataSource.GetViewNames ().Count > 0;
45 public static IList GetList (IDataSource dataSource)
47 if (dataSource.GetViewNames ().Count == 0)
48 return null;
50 ListSourceList list = new ListSourceList ();
51 list.Add (dataSource);
52 return list;
55 sealed class ListSourceList : List<IDataSource>, ITypedList
57 #region ITypedList Members
59 PropertyDescriptorCollection ITypedList.GetItemProperties (PropertyDescriptor [] listAccessors) {
60 ICollection viewNames = this [0].GetViewNames ();
61 PropertyDescriptor [] a = new PropertyDescriptor [viewNames.Count];
62 int i = 0;
63 foreach (string viewName in viewNames) {
64 a[i++] = new ListSourcePropertyDescriptor (viewName, null);
66 return new PropertyDescriptorCollection (a);
69 string ITypedList.GetListName (PropertyDescriptor [] listAccessors) {
70 return String.Empty;
73 #endregion
76 sealed class ListSourcePropertyDescriptor : PropertyDescriptor
78 public ListSourcePropertyDescriptor (MemberDescriptor descr)
79 : base (descr) {
82 public ListSourcePropertyDescriptor (string name, Attribute [] attrs)
83 : base (name, attrs) {
86 public ListSourcePropertyDescriptor (MemberDescriptor descr, Attribute [] attrs)
87 : base (descr, attrs) {
90 public override bool CanResetValue (object component) {
91 throw new NotImplementedException ();
94 public override Type ComponentType {
95 get { throw new NotImplementedException (); }
98 public override object GetValue (object component) {
99 IDataSource dataSource = component as IDataSource;
100 if (dataSource == null)
101 return null;
103 DataSourceView view = dataSource.GetView (Name);
104 return view.ExecuteSelect (DataSourceSelectArguments.Empty);
107 public override bool IsReadOnly {
108 get { return true; }
111 public override Type PropertyType {
112 get { return typeof(IEnumerable); }
115 public override void ResetValue (object component) {
116 throw new NotImplementedException ();
119 public override void SetValue (object component, object value) {
120 throw new NotImplementedException ();
123 public override bool ShouldSerializeValue (object component) {
124 throw new NotImplementedException ();