Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Data / System / Data / DefaultValueTypeConverter.cs / 1 / DefaultValueTypeConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //[....] //----------------------------------------------------------------------------- /* */ namespace System.Data { using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Globalization; ////// internal sealed class DefaultValueTypeConverter : StringConverter { private static string nullString = "Provides a type /// converter that can be used to populate a list box with available types. ///"; private static string dbNullString = " "; // converter classes should have public ctor public DefaultValueTypeConverter() { } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string)) { if (value == null) { return nullString; } else if (value == DBNull.Value) { return dbNullString; } } return base.ConvertTo(context, culture, value, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value != null && value.GetType() == typeof(string)) { string strValue = (string)value; if (string.Compare(strValue, nullString, StringComparison.OrdinalIgnoreCase) == 0) return null; else if (string.Compare(strValue, dbNullString, StringComparison.OrdinalIgnoreCase) == 0) return DBNull.Value; } return base.ConvertFrom(context, culture, value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SplitterCancelEvent.cs
- MobileResource.cs
- ExpandedWrapper.cs
- ButtonField.cs
- GetPageCompletedEventArgs.cs
- DynamicPropertyHolder.cs
- MediaTimeline.cs
- PropertyTabAttribute.cs
- EntityDataSourceView.cs
- ObservableCollectionDefaultValueFactory.cs
- ToolBarOverflowPanel.cs
- ReplacementText.cs
- EntityException.cs
- SqlDataSourceStatusEventArgs.cs
- FileUtil.cs
- PagedDataSource.cs
- FontUnitConverter.cs
- AlphabeticalEnumConverter.cs
- XPathPatternParser.cs
- uribuilder.cs
- _NativeSSPI.cs
- Relationship.cs
- AncestorChangedEventArgs.cs
- X509ThumbprintKeyIdentifierClause.cs
- ToolStripLabel.cs
- DES.cs
- ResolvedKeyFrameEntry.cs
- XPathNodePointer.cs
- InvalidFilterCriteriaException.cs
- CompiledAction.cs
- Attachment.cs
- ResetableIterator.cs
- Inflater.cs
- TagNameToTypeMapper.cs
- ConsumerConnectionPoint.cs
- XmlDataSourceView.cs
- Package.cs
- OpenFileDialog.cs
- Timer.cs
- SettingsProperty.cs
- ScaleTransform3D.cs
- CqlParser.cs
- XamlReader.cs
- ConfigurationProperty.cs
- ValidationPropertyAttribute.cs
- ObjectStateManager.cs
- PolicyLevel.cs
- LineGeometry.cs
- StylusPointProperty.cs
- ReliabilityContractAttribute.cs
- FrameSecurityDescriptor.cs
- FilterException.cs
- ObjectQuery_EntitySqlExtensions.cs
- SimpleWebHandlerParser.cs
- ListBoxDesigner.cs
- DataGridToolTip.cs
- DetailsViewModeEventArgs.cs
- LinearQuaternionKeyFrame.cs
- VisualCollection.cs
- InvokeMemberBinder.cs
- OdbcCommandBuilder.cs
- mactripleDES.cs
- ScriptServiceAttribute.cs
- StateChangeEvent.cs
- XpsS0ValidatingLoader.cs
- CustomActivityDesigner.cs
- SqlProfileProvider.cs
- ConfigXmlCDataSection.cs
- GlobalProxySelection.cs
- DataConnectionHelper.cs
- TimeSpan.cs
- SaveFileDialog.cs
- SizeAnimationClockResource.cs
- PrintPreviewControl.cs
- Token.cs
- QueryTreeBuilder.cs
- FixedStringLookup.cs
- StreamInfo.cs
- _IPv4Address.cs
- TimeZone.cs
- WebPartConnectionsCancelVerb.cs
- LinearGradientBrush.cs
- DataStreams.cs
- TypographyProperties.cs
- TextSegment.cs
- TransportChannelFactory.cs
- InstanceNotReadyException.cs
- SchemaSetCompiler.cs
- ConstrainedGroup.cs
- Cursor.cs
- EventLogPermission.cs
- VsPropertyGrid.cs
- GridViewRowEventArgs.cs
- WindowsContainer.cs
- HostedTransportConfigurationManager.cs
- ProfileEventArgs.cs
- SpeechRecognizer.cs
- NumericUpDown.cs
- ReceiveSecurityHeaderElementManager.cs
- EntityDataSourceChangedEventArgs.cs