Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Data / System / Data / DataViewManagerListItemTypeDescriptor.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="DataViewManagerListItemTypeDescriptor.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>                                                                
5 // <owner current="true" primary="true">[....]</owner>
6 // <owner current="true" primary="false">[....]</owner>
7 // <owner current="false" primary="false">[....]</owner>
8 //------------------------------------------------------------------------------
9
10 namespace System.Data {
11     using System;
12     using System.ComponentModel;
13
14     /// <devdoc>
15     ///    <para>[To be supplied.]</para>
16     /// </devdoc>
17     internal sealed class DataViewManagerListItemTypeDescriptor : ICustomTypeDescriptor {
18
19         private DataViewManager dataViewManager;
20         private PropertyDescriptorCollection propsCollection;
21
22         internal DataViewManagerListItemTypeDescriptor(DataViewManager dataViewManager) {
23             this.dataViewManager = dataViewManager;
24         }
25
26         internal void Reset() {
27             propsCollection = null;
28         }
29
30         internal DataView GetDataView(DataTable table) {
31             DataView dataView = new DataView(table);
32             dataView.SetDataViewManager(dataViewManager);
33             return dataView;
34         }        
35
36         /// <devdoc>
37         ///     Retrieves an array of member attributes for the given object.
38         /// </devdoc>
39         AttributeCollection ICustomTypeDescriptor.GetAttributes() {
40             return new AttributeCollection((Attribute[])null);
41         }
42
43         /// <devdoc>
44         ///     Retrieves the class name for this object.  If null is returned,
45         ///     the type name is used.
46         /// </devdoc>
47         string ICustomTypeDescriptor.GetClassName() {
48             return null;
49         }
50
51         /// <devdoc>
52         ///     Retrieves the name for this object.  If null is returned,
53         ///     the default is used.
54         /// </devdoc>
55         string ICustomTypeDescriptor.GetComponentName() {
56             return null;
57         }
58
59         /// <devdoc>
60         ///      Retrieves the type converter for this object.
61         /// </devdoc>
62         TypeConverter ICustomTypeDescriptor.GetConverter() {
63             return null;
64         }
65
66         /// <devdoc>
67         ///     Retrieves the default event.
68         /// </devdoc>
69         EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() {
70             return null;
71         }
72
73
74         /// <devdoc>
75         ///     Retrieves the default property.
76         /// </devdoc>
77         PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() {
78             return null;
79         }
80
81         /// <devdoc>
82         ///      Retrieves the an editor for this object.
83         /// </devdoc>
84         object ICustomTypeDescriptor.GetEditor(Type editorBaseType) {
85             return null;
86         }
87
88         /// <devdoc>
89         ///     Retrieves an array of events that the given component instance
90         ///     provides.  This may differ from the set of events the class
91         ///     provides.  If the component is sited, the site may add or remove
92         ///     additional events.
93         /// </devdoc>
94         EventDescriptorCollection ICustomTypeDescriptor.GetEvents() {
95             return new EventDescriptorCollection(null);
96         }
97
98         /// <devdoc>
99         ///     Retrieves an array of events that the given component instance
100         ///     provides.  This may differ from the set of events the class
101         ///     provides.  If the component is sited, the site may add or remove
102         ///     additional events.  The returned array of events will be
103         ///     filtered by the given set of attributes.
104         /// </devdoc>
105         EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) {
106             return new EventDescriptorCollection(null);
107         }
108
109         /// <devdoc>
110         ///     Retrieves an array of properties that the given component instance
111         ///     provides.  This may differ from the set of properties the class
112         ///     provides.  If the component is sited, the site may add or remove
113         ///     additional properties.
114         /// </devdoc>
115         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() {
116             return((ICustomTypeDescriptor)this).GetProperties(null);
117         }
118
119         /// <devdoc>
120         ///     Retrieves an array of properties that the given component instance
121         ///     provides.  This may differ from the set of properties the class
122         ///     provides.  If the component is sited, the site may add or remove
123         ///     additional properties.  The returned array of properties will be
124         ///     filtered by the given set of attributes.
125         /// </devdoc>
126         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) {
127             if (propsCollection == null) {
128                 PropertyDescriptor[] props = null;
129                 DataSet dataSet = dataViewManager.DataSet;
130                 if (dataSet != null) {
131                     int tableCount = dataSet.Tables.Count;
132                     props = new PropertyDescriptor[tableCount];
133                     for (int i = 0; i < tableCount; i++) {
134                         props[i] = new DataTablePropertyDescriptor(dataSet.Tables[i]);
135                     }
136                 }                                
137                 propsCollection = new PropertyDescriptorCollection(props);
138             }
139             return propsCollection;
140         }
141
142         /// <devdoc>
143         ///     Retrieves the object that directly depends on this value being edited.  This is
144         ///     generally the object that is required for the PropertyDescriptor's GetValue and SetValue
145         ///     methods.  If 'null' is passed for the PropertyDescriptor, the ICustomComponent
146         ///     descripotor implemementation should return the default object, that is the main
147         ///     object that exposes the properties and attributes,
148         /// </devdoc>
149         object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) {
150             return this;
151         }
152     }   
153 }