Inheritance: System.ComponentModel.PropertyDescriptor
示例#1
0
 public override bool Equals(object other)
 {
     if (other is DataRelationPropertyDescriptor)
     {
         DataRelationPropertyDescriptor descriptor = (DataRelationPropertyDescriptor)other;
         return(descriptor.Relation == this.Relation);
     }
     return(false);
 }
 public override bool Equals([NotNullWhen(true)] object?other)
 {
     if (other is DataRelationPropertyDescriptor)
     {
         DataRelationPropertyDescriptor descriptor = (DataRelationPropertyDescriptor)other;
         return(descriptor.Relation == Relation);
     }
     return(false);
 }
示例#3
0
 protected virtual void RelationCollectionChanged(object sender, CollectionChangeEventArgs e) {
     DataRelationPropertyDescriptor NullProp = null;
     OnListChanged(
         e.Action == CollectionChangeAction.Add ? new ListChangedEventArgs(ListChangedType.PropertyDescriptorAdded, new DataRelationPropertyDescriptor((System.Data.DataRelation)e.Element)) :
         e.Action == CollectionChangeAction.Refresh ? new ListChangedEventArgs(ListChangedType.PropertyDescriptorChanged, NullProp):
         e.Action == CollectionChangeAction.Remove ? new ListChangedEventArgs(ListChangedType.PropertyDescriptorDeleted, new DataRelationPropertyDescriptor((System.Data.DataRelation)e.Element)) :
     /*default*/ null
     );
 }
        public override bool Equals(object obj)
        {
            DataRelationPropertyDescriptor descriptor = obj as DataRelationPropertyDescriptor;

            if (descriptor == null)
            {
                return(false);
            }

            return(Relation == descriptor.Relation);
        }
示例#5
0
        private ListChangedEventArgs CollectionToListChangeEventArgs(CollectionChangeEventArgs e)
        {
            ListChangedEventArgs args;

            if (e.Action == CollectionChangeAction.Remove)
            {
                args = null;
            }
            else if (e.Action == CollectionChangeAction.Refresh)
            {
                args = new ListChangedEventArgs(ListChangedType.PropertyDescriptorChanged, null);
            }
            else
            {
                object obj;

                if (typeof(DataTable).IsAssignableFrom(e.Element.GetType()))
                {
                    obj = new DataTablePropertyDescriptor((DataTable)e.Element);
                }
                else                // Assume a DataRelation
                {
                    obj = new DataRelationPropertyDescriptor((DataRelation)e.Element);
                }

                if (e.Action == CollectionChangeAction.Add)
                {
                    args = new ListChangedEventArgs(ListChangedType.PropertyDescriptorAdded, (PropertyDescriptor)obj);
                }
                else
                {
                    args = new ListChangedEventArgs(ListChangedType.PropertyDescriptorDeleted, (PropertyDescriptor)obj);
                }
            }

            return(args);
        }
示例#6
0
        PropertyDescriptorCollection ITypedList.GetItemProperties(PropertyDescriptor [] listAccessors)
        {
            if (dataTable == null)
            {
                return(new PropertyDescriptorCollection(new PropertyDescriptor [0]));
            }

            // FIXME: use listAccessors somehow
            PropertyDescriptor [] descriptors =
                new PropertyDescriptor [dataTable.Columns.Count + dataTable.ChildRelations.Count];

            int d = 0;

            for (int col = 0; col < dataTable.Columns.Count; col++)
            {
                DataColumn dataColumn = dataTable.Columns[col];
                DataColumnPropertyDescriptor descriptor;

                descriptor = new DataColumnPropertyDescriptor(dataColumn.ColumnName, col, null);
                descriptor.SetComponentType(typeof(System.Data.DataRowView));
                descriptor.SetPropertyType(dataColumn.DataType);
                descriptor.SetReadOnly(dataColumn.ReadOnly);
                descriptor.SetBrowsable(dataColumn.ColumnMapping != MappingType.Hidden);
                descriptors [d++] = descriptor;
            }
            for (int rel = 0; rel < dataTable.ChildRelations.Count; rel++)
            {
                DataRelation dataRelation = dataTable.ChildRelations [rel];
                DataRelationPropertyDescriptor descriptor;

                descriptor        = new DataRelationPropertyDescriptor(dataRelation);
                descriptors [d++] = descriptor;
            }

            return(new PropertyDescriptorCollection(descriptors));
        }
示例#7
0
 /// <devdoc>
 ///     Retrieves an array of properties that the given component instance
 ///     provides.  This may differ from the set of properties the class
 ///     provides.  If the component is sited, the site may add or remove
 ///     additional properties.  The returned array of properties will be
 ///     filtered by the given set of attributes.
 /// </devdoc>
 internal PropertyDescriptorCollection GetPropertyDescriptorCollection(Attribute[] attributes) {
     if (propertyDescriptorCollectionCache == null) {
         int columnsCount   = Columns.Count;
         int relationsCount = ChildRelations.Count;
         PropertyDescriptor[] props = new PropertyDescriptor[columnsCount + relationsCount]; {
             for (int i = 0; i < columnsCount; i++) {
                 props[i] = new DataColumnPropertyDescriptor(Columns[i]);
             }
             for (int i = 0; i < relationsCount; i++) {
                 props[columnsCount + i] = new DataRelationPropertyDescriptor(ChildRelations[i]);
             }
         }
         propertyDescriptorCollectionCache = new PropertyDescriptorCollection(props);
     }
     return propertyDescriptorCollectionCache;
 }
示例#8
0
		private ListChangedEventArgs CollectionToListChangeEventArgs (CollectionChangeEventArgs e)
		{
			ListChangedEventArgs args;

			if (e.Action == CollectionChangeAction.Remove)
				args = null;
			else if (e.Action == CollectionChangeAction.Refresh)
				args = new ListChangedEventArgs(ListChangedType.PropertyDescriptorChanged, null);
			else { 
			       object obj;
			       
			       if (typeof (DataTable).IsAssignableFrom (e.Element.GetType()))
			               obj = new DataTablePropertyDescriptor ((DataTable) e.Element);
			       else // Assume a DataRelation
			               obj = new DataRelationPropertyDescriptor((DataRelation) e.Element);
			       
			       if (e.Action == CollectionChangeAction.Add)
			               args = new ListChangedEventArgs(ListChangedType.PropertyDescriptorAdded, (PropertyDescriptor) obj);
			       else
			               args = new ListChangedEventArgs(ListChangedType.PropertyDescriptorDeleted, (PropertyDescriptor) obj);
			}
			
			return args;
		}
示例#9
0
文件: DataTable.cs 项目: shana/mono
		private void UpdatePropertyDescriptorsCache ()
		{
			PropertyDescriptor[] descriptors = new PropertyDescriptor[Columns.Count + ChildRelations.Count];
			int index = 0;
			foreach (DataColumn col in Columns)
				descriptors [index++] = new DataColumnPropertyDescriptor (col);

			foreach (DataRelation rel in ChildRelations)
				descriptors [index++] = new DataRelationPropertyDescriptor (rel);

			_propertyDescriptorsCache = new PropertyDescriptorCollection (descriptors);
		}
示例#10
0
		PropertyDescriptorCollection ITypedList.GetItemProperties (PropertyDescriptor [] listAccessors)
		{
			if (dataTable == null)
				return new PropertyDescriptorCollection (new PropertyDescriptor [0]);

			// FIXME: use listAccessors somehow
			PropertyDescriptor [] descriptors =
				new PropertyDescriptor [dataTable.Columns.Count + dataTable.ChildRelations.Count];

			int d = 0;
			for (int col = 0; col < dataTable.Columns.Count; col ++) {
				DataColumn dataColumn = dataTable.Columns[col];
				DataColumnPropertyDescriptor descriptor;

				descriptor = new DataColumnPropertyDescriptor (dataColumn.ColumnName, col, null);
				descriptor.SetComponentType (typeof (System.Data.DataRowView));
				descriptor.SetPropertyType (dataColumn.DataType);
				descriptor.SetReadOnly (dataColumn.ReadOnly);
				descriptor.SetBrowsable (dataColumn.ColumnMapping != MappingType.Hidden);
				descriptors [d++] = descriptor;
			}
			for (int rel = 0; rel < dataTable.ChildRelations.Count; rel ++) {
				DataRelation dataRelation = dataTable.ChildRelations [rel];
				DataRelationPropertyDescriptor descriptor;

				descriptor = new DataRelationPropertyDescriptor (dataRelation);
				descriptors [d++] = descriptor;
			}

			return new PropertyDescriptorCollection (descriptors);
		}
 internal PropertyDescriptorCollection GetPropertyDescriptorCollection(Attribute[] attributes)
 {
     if (this.propertyDescriptorCollectionCache == null)
     {
         int count = this.Columns.Count;
         int num4 = this.ChildRelations.Count;
         PropertyDescriptor[] properties = new PropertyDescriptor[count + num4];
         for (int i = 0; i < count; i++)
         {
             properties[i] = new DataColumnPropertyDescriptor(this.Columns[i]);
         }
         for (int j = 0; j < num4; j++)
         {
             properties[count + j] = new DataRelationPropertyDescriptor(this.ChildRelations[j]);
         }
         this.propertyDescriptorCollectionCache = new PropertyDescriptorCollection(properties);
     }
     return this.propertyDescriptorCollectionCache;
 }
示例#12
0
        protected virtual void RelationCollectionChanged(object sender, CollectionChangeEventArgs e)
        {
            DataRelationPropertyDescriptor propDesc = null;

            this.OnListChanged((e.Action == CollectionChangeAction.Add) ? new ListChangedEventArgs(ListChangedType.PropertyDescriptorAdded, new DataRelationPropertyDescriptor((DataRelation)e.Element)) : ((e.Action == CollectionChangeAction.Refresh) ? new ListChangedEventArgs(ListChangedType.PropertyDescriptorChanged, propDesc) : ((e.Action == CollectionChangeAction.Remove) ? new ListChangedEventArgs(ListChangedType.PropertyDescriptorDeleted, new DataRelationPropertyDescriptor((DataRelation)e.Element)) : null)));
        }