Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / DataColumnPropertyDescriptor.cs / 1305376 / DataColumnPropertyDescriptor.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data {
using System.Diagnostics;
using System.ComponentModel;
using System.Data.Common;
internal sealed class DataColumnPropertyDescriptor : PropertyDescriptor {
DataColumn column;
internal DataColumnPropertyDescriptor(DataColumn dataColumn) : base(dataColumn.ColumnName, null) {
this.column = dataColumn;
}
public override AttributeCollection Attributes {
get {
if (typeof(System.Collections.IList).IsAssignableFrom(this.PropertyType)) {
Attribute[] attrs = new Attribute[base.Attributes.Count + 1];
base.Attributes.CopyTo(attrs, 0);
// we don't want to show the columns which are of type IList in the designer
attrs[attrs.Length - 1] = new ListBindableAttribute(false);
return new AttributeCollection(attrs);
} else {
return base.Attributes;
}
}
}
internal DataColumn Column {
get {
return column;
}
}
public override Type ComponentType {
get {
return typeof(DataRowView);
}
}
public override bool IsReadOnly {
get {
return column.ReadOnly;
}
}
public override Type PropertyType {
get {
return column.DataType;
}
}
public override bool Equals(object other) {
if (other is DataColumnPropertyDescriptor) {
DataColumnPropertyDescriptor descriptor = (DataColumnPropertyDescriptor) other;
return(descriptor.Column == Column);
}
return false;
}
public override Int32 GetHashCode() {
return Column.GetHashCode();
}
public override bool CanResetValue(object component) {
DataRowView dataRowView = (DataRowView) component;
if (!column.IsSqlType)
return (dataRowView.GetColumnValue(column) != DBNull.Value);
return (!DataStorage.IsObjectNull(dataRowView.GetColumnValue(column)));
}
public override object GetValue(object component) {
DataRowView dataRowView = (DataRowView) component;
return dataRowView.GetColumnValue(column);
}
public override void ResetValue(object component) {
DataRowView dataRowView = (DataRowView) component;
dataRowView.SetColumnValue(column, DBNull.Value);// no need to ccheck for the col type and set Sql...Null!
}
public override void SetValue(object component, object value) {
DataRowView dataRowView = (DataRowView) component;
dataRowView.SetColumnValue(column, value);
OnValueChanged(component, EventArgs.Empty);
}
public override bool ShouldSerializeValue(object component) {
return false;
}
public override bool IsBrowsable {
get {
return (column.ColumnMapping == System.Data.MappingType.Hidden ? false : base.IsBrowsable);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data {
using System.Diagnostics;
using System.ComponentModel;
using System.Data.Common;
internal sealed class DataColumnPropertyDescriptor : PropertyDescriptor {
DataColumn column;
internal DataColumnPropertyDescriptor(DataColumn dataColumn) : base(dataColumn.ColumnName, null) {
this.column = dataColumn;
}
public override AttributeCollection Attributes {
get {
if (typeof(System.Collections.IList).IsAssignableFrom(this.PropertyType)) {
Attribute[] attrs = new Attribute[base.Attributes.Count + 1];
base.Attributes.CopyTo(attrs, 0);
// we don't want to show the columns which are of type IList in the designer
attrs[attrs.Length - 1] = new ListBindableAttribute(false);
return new AttributeCollection(attrs);
} else {
return base.Attributes;
}
}
}
internal DataColumn Column {
get {
return column;
}
}
public override Type ComponentType {
get {
return typeof(DataRowView);
}
}
public override bool IsReadOnly {
get {
return column.ReadOnly;
}
}
public override Type PropertyType {
get {
return column.DataType;
}
}
public override bool Equals(object other) {
if (other is DataColumnPropertyDescriptor) {
DataColumnPropertyDescriptor descriptor = (DataColumnPropertyDescriptor) other;
return(descriptor.Column == Column);
}
return false;
}
public override Int32 GetHashCode() {
return Column.GetHashCode();
}
public override bool CanResetValue(object component) {
DataRowView dataRowView = (DataRowView) component;
if (!column.IsSqlType)
return (dataRowView.GetColumnValue(column) != DBNull.Value);
return (!DataStorage.IsObjectNull(dataRowView.GetColumnValue(column)));
}
public override object GetValue(object component) {
DataRowView dataRowView = (DataRowView) component;
return dataRowView.GetColumnValue(column);
}
public override void ResetValue(object component) {
DataRowView dataRowView = (DataRowView) component;
dataRowView.SetColumnValue(column, DBNull.Value);// no need to ccheck for the col type and set Sql...Null!
}
public override void SetValue(object component, object value) {
DataRowView dataRowView = (DataRowView) component;
dataRowView.SetColumnValue(column, value);
OnValueChanged(component, EventArgs.Empty);
}
public override bool ShouldSerializeValue(object component) {
return false;
}
public override bool IsBrowsable {
get {
return (column.ColumnMapping == System.Data.MappingType.Hidden ? false : base.IsBrowsable);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Span.cs
- TcpActivation.cs
- ToolBarButtonClickEvent.cs
- EntityDataSource.cs
- XmlSiteMapProvider.cs
- ValuePatternIdentifiers.cs
- validation.cs
- RawTextInputReport.cs
- SafeHandle.cs
- XpsFilter.cs
- HttpResponse.cs
- ListViewDesigner.cs
- EnvelopedPkcs7.cs
- ListItemParagraph.cs
- MDIControlStrip.cs
- GlyphingCache.cs
- DataGridViewCellStateChangedEventArgs.cs
- StatusCommandUI.cs
- ListItemParagraph.cs
- RightsManagementPermission.cs
- ListViewInsertedEventArgs.cs
- OracleFactory.cs
- InvokeAction.cs
- VoiceInfo.cs
- ErrorReporting.cs
- Baml2006KeyRecord.cs
- FilterQueryOptionExpression.cs
- InkCanvasAutomationPeer.cs
- DataGridViewSortCompareEventArgs.cs
- OdbcStatementHandle.cs
- PagedDataSource.cs
- TaiwanLunisolarCalendar.cs
- DataRecord.cs
- DiscoveryDocumentSerializer.cs
- CustomErrorsSection.cs
- Transform3D.cs
- SqlRowUpdatingEvent.cs
- WriteFileContext.cs
- DataGridViewElement.cs
- EntityDataSourceView.cs
- NamespaceQuery.cs
- DataBoundControlHelper.cs
- MonthChangedEventArgs.cs
- SmtpDigestAuthenticationModule.cs
- SpeechSeg.cs
- XmlCollation.cs
- UxThemeWrapper.cs
- SystemResourceKey.cs
- Normalization.cs
- CodeDOMProvider.cs
- WebPartEditorOkVerb.cs
- ServiceTimeoutsElement.cs
- ControlAdapter.cs
- FeatureSupport.cs
- DataGridViewColumnCollectionDialog.cs
- VectorKeyFrameCollection.cs
- SqlDataSource.cs
- XmlWriterDelegator.cs
- PtsHelper.cs
- DataGridViewDataConnection.cs
- CodeExpressionCollection.cs
- ContextMenu.cs
- TextTabProperties.cs
- TimeIntervalCollection.cs
- TrustLevel.cs
- StrongNamePublicKeyBlob.cs
- QueryPageSettingsEventArgs.cs
- BufferAllocator.cs
- ScrollPattern.cs
- Compiler.cs
- EncoderExceptionFallback.cs
- TouchEventArgs.cs
- ITextView.cs
- SelectManyQueryOperator.cs
- XmlSchemaAnnotated.cs
- CultureTableRecord.cs
- Oid.cs
- KnownBoxes.cs
- DbQueryCommandTree.cs
- OpenTypeLayout.cs
- SpecialTypeDataContract.cs
- PropertyCollection.cs
- FloaterParaClient.cs
- ErrorFormatter.cs
- MethodRental.cs
- RegistryPermission.cs
- DataFieldEditor.cs
- MobileContainerDesigner.cs
- Image.cs
- SpoolingTask.cs
- QuaternionRotation3D.cs
- TreeBuilderBamlTranslator.cs
- KeyInstance.cs
- FontDifferentiator.cs
- ObjectDataSourceMethodEventArgs.cs
- MonitorWrapper.cs
- ReturnValue.cs
- OdbcParameterCollection.cs
- DiscreteKeyFrames.cs
- ParameterBinding.cs