2003-02-18 Alan Tam <Tam@SiuLung.com>
[mono.git] / mcs / class / System.Data / System.Data / DataTablePropertyDescriptor.cs
1 //
2 // System.Data.DataTablePropertyDescriptor
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2003 Ximian, Inc (http://www.ximian.com)
8 //
9
10 using System;
11 using System.ComponentModel;
12
13 namespace System.Data
14 {
15         internal class DataTablePropertyDescriptor : PropertyDescriptor
16         {
17                 DataTable table;
18
19                 internal DataTablePropertyDescriptor (DataTable table) : base (table.TableName, null)
20                 {
21                         this.table = table;
22                 }
23
24                 public DataTable Table {
25                         get { return table; }
26                 }
27
28                 public override object GetValue (object component)
29                 {
30                         DataViewManagerListItemTypeDescriptor desc = component as DataViewManagerListItemTypeDescriptor;
31                         if (desc == null)
32                                 return null;
33
34                         DataView dv = new DataView (table);
35                         dv.dataViewManager = desc.DataViewManager;
36                         return dv;
37                 }
38
39                 public override bool CanResetValue (object component)
40                 {
41                         return false;
42                 }
43
44                 public override bool Equals (object other)
45                 {
46                         return (other is DataTablePropertyDescriptor && 
47                                 ((DataTablePropertyDescriptor) other).table == table);
48                 }
49
50                 public override int GetHashCode ()
51                 {
52                         return table.GetHashCode ();
53                 }
54
55                 public override bool ShouldSerializeValue (object component)
56                 {
57                         return false;
58                 }
59
60                 public override void ResetValue (object component)
61                 {
62                 }
63
64                 public override void SetValue (object component, object value)
65                 {
66                 }
67
68                 public override bool IsReadOnly
69                 {
70                         get { return false; }
71                 }
72
73                 public override Type ComponentType
74                 {
75                         get { return typeof (DataRowView); }
76                 }
77
78                 public override Type PropertyType
79                 {
80                         get { return typeof (IBindingList); }
81                 }
82         }
83 }
84