1 //------------------------------------------------------------------------------
2 // <copyright file="DataViewManagerListItemTypeDescriptor.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">[....]</owner>
6 // <owner current="true" primary="false">[....]</owner>
7 // <owner current="false" primary="false">[....]</owner>
8 //------------------------------------------------------------------------------
10 namespace System.Data {
12 using System.ComponentModel;
15 /// <para>[To be supplied.]</para>
17 internal sealed class DataViewManagerListItemTypeDescriptor : ICustomTypeDescriptor {
19 private DataViewManager dataViewManager;
20 private PropertyDescriptorCollection propsCollection;
22 internal DataViewManagerListItemTypeDescriptor(DataViewManager dataViewManager) {
23 this.dataViewManager = dataViewManager;
26 internal void Reset() {
27 propsCollection = null;
30 internal DataView GetDataView(DataTable table) {
31 DataView dataView = new DataView(table);
32 dataView.SetDataViewManager(dataViewManager);
37 /// Retrieves an array of member attributes for the given object.
39 AttributeCollection ICustomTypeDescriptor.GetAttributes() {
40 return new AttributeCollection((Attribute[])null);
44 /// Retrieves the class name for this object. If null is returned,
45 /// the type name is used.
47 string ICustomTypeDescriptor.GetClassName() {
52 /// Retrieves the name for this object. If null is returned,
53 /// the default is used.
55 string ICustomTypeDescriptor.GetComponentName() {
60 /// Retrieves the type converter for this object.
62 TypeConverter ICustomTypeDescriptor.GetConverter() {
67 /// Retrieves the default event.
69 EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() {
75 /// Retrieves the default property.
77 PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() {
82 /// Retrieves the an editor for this object.
84 object ICustomTypeDescriptor.GetEditor(Type editorBaseType) {
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.
94 EventDescriptorCollection ICustomTypeDescriptor.GetEvents() {
95 return new EventDescriptorCollection(null);
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.
105 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) {
106 return new EventDescriptorCollection(null);
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.
115 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() {
116 return((ICustomTypeDescriptor)this).GetProperties(null);
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.
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]);
137 propsCollection = new PropertyDescriptorCollection(props);
139 return propsCollection;
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,
149 object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) {