Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / System.Data / System / Data / DataColumnPropertyDescriptor.cs
blobe99ccf43b8d87d2e17947fa7dc8efa5f870473ea
1 //------------------------------------------------------------------------------
2 // <copyright file="DataColumnPropertyDescriptor.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="true" primary="false">Microsoft</owner>
7 // <owner current="false" primary="false">Microsoft</owner>
8 //------------------------------------------------------------------------------
10 namespace System.Data {
11 using System.Diagnostics;
12 using System.ComponentModel;
13 using System.Data.Common;
15 internal sealed class DataColumnPropertyDescriptor : PropertyDescriptor {
17 DataColumn column;
19 internal DataColumnPropertyDescriptor(DataColumn dataColumn) : base(dataColumn.ColumnName, null) {
20 this.column = dataColumn;
23 public override AttributeCollection Attributes {
24 get {
25 if (typeof(System.Collections.IList).IsAssignableFrom(this.PropertyType)) {
26 Attribute[] attrs = new Attribute[base.Attributes.Count + 1];
27 base.Attributes.CopyTo(attrs, 0);
28 // we don't want to show the columns which are of type IList in the designer
29 attrs[attrs.Length - 1] = new ListBindableAttribute(false);
30 return new AttributeCollection(attrs);
31 } else {
32 return base.Attributes;
37 internal DataColumn Column {
38 get {
39 return column;
43 public override Type ComponentType {
44 get {
45 return typeof(DataRowView);
49 public override bool IsReadOnly {
50 get {
51 return column.ReadOnly;
55 public override Type PropertyType {
56 get {
57 return column.DataType;
61 public override bool Equals(object other) {
62 if (other is DataColumnPropertyDescriptor) {
63 DataColumnPropertyDescriptor descriptor = (DataColumnPropertyDescriptor) other;
64 return(descriptor.Column == Column);
66 return false;
69 public override Int32 GetHashCode() {
70 return Column.GetHashCode();
73 public override bool CanResetValue(object component) {
74 DataRowView dataRowView = (DataRowView) component;
75 if (!column.IsSqlType)
76 return (dataRowView.GetColumnValue(column) != DBNull.Value);
77 return (!DataStorage.IsObjectNull(dataRowView.GetColumnValue(column)));
80 public override object GetValue(object component) {
81 DataRowView dataRowView = (DataRowView) component;
82 return dataRowView.GetColumnValue(column);
85 public override void ResetValue(object component) {
86 DataRowView dataRowView = (DataRowView) component;
87 dataRowView.SetColumnValue(column, DBNull.Value);// no need to ccheck for the col type and set Sql...Null!
90 public override void SetValue(object component, object value) {
91 DataRowView dataRowView = (DataRowView) component;
92 dataRowView.SetColumnValue(column, value);
93 OnValueChanged(component, EventArgs.Empty);
96 public override bool ShouldSerializeValue(object component) {
97 return false;
100 public override bool IsBrowsable {
101 get {
102 return (column.ColumnMapping == System.Data.MappingType.Hidden ? false : base.IsBrowsable);