Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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. // //[....] //[....] //[....] //----------------------------------------------------------------------------- /* */ 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RSAOAEPKeyExchangeDeformatter.cs
- ObjectHandle.cs
- ColumnClickEvent.cs
- _CommandStream.cs
- XmlSchemaAttribute.cs
- PointValueSerializer.cs
- TableHeaderCell.cs
- EmptyControlCollection.cs
- DbExpressionVisitor_TResultType.cs
- StreamFormatter.cs
- EncodingDataItem.cs
- Timer.cs
- ApplicationCommands.cs
- NameScope.cs
- PropertyPath.cs
- EditingScopeUndoUnit.cs
- XhtmlTextWriter.cs
- Win32.cs
- KeySpline.cs
- TypefaceMetricsCache.cs
- MimeTypeAttribute.cs
- CommonServiceBehaviorElement.cs
- LinqDataSourceStatusEventArgs.cs
- SQLInt16Storage.cs
- TouchPoint.cs
- ProxyManager.cs
- CursorConverter.cs
- Transform.cs
- DebugTraceHelper.cs
- AttributeUsageAttribute.cs
- LabelEditEvent.cs
- SqlClientMetaDataCollectionNames.cs
- AutomationEventArgs.cs
- XmlUTF8TextWriter.cs
- StaticSiteMapProvider.cs
- HwndStylusInputProvider.cs
- XmlRawWriter.cs
- SmtpException.cs
- BaseProcessor.cs
- WinCategoryAttribute.cs
- ListChangedEventArgs.cs
- IssuedTokensHeader.cs
- PathHelper.cs
- MouseCaptureWithinProperty.cs
- ScrollBarAutomationPeer.cs
- DiagnosticsConfiguration.cs
- TableItemProviderWrapper.cs
- WindowsTreeView.cs
- TypedAsyncResult.cs
- WebPartCloseVerb.cs
- XPathParser.cs
- TextServicesCompartment.cs
- SizeAnimationUsingKeyFrames.cs
- CmsUtils.cs
- XamlToRtfWriter.cs
- SessionStateModule.cs
- SafeRightsManagementQueryHandle.cs
- StandardToolWindows.cs
- ISCIIEncoding.cs
- RawStylusSystemGestureInputReport.cs
- WebPartExportVerb.cs
- XMLSchema.cs
- RelationshipConverter.cs
- RowBinding.cs
- _DigestClient.cs
- SoundPlayer.cs
- ContextQuery.cs
- ScriptMethodAttribute.cs
- Separator.cs
- StreamFormatter.cs
- SuppressIldasmAttribute.cs
- TypeConverterHelper.cs
- UnicastIPAddressInformationCollection.cs
- PageParserFilter.cs
- CurrentChangingEventManager.cs
- BufferAllocator.cs
- ExpressionContext.cs
- AutoCompleteStringCollection.cs
- SerialStream.cs
- DbConnectionStringBuilder.cs
- PageContentAsyncResult.cs
- XmlDomTextWriter.cs
- FacetValueContainer.cs
- EqualityArray.cs
- KeyValueInternalCollection.cs
- QilXmlReader.cs
- BuildResultCache.cs
- TargetConverter.cs
- EmptyControlCollection.cs
- FormViewAutoFormat.cs
- ContractHandle.cs
- BooleanProjectedSlot.cs
- InputElement.cs
- NameObjectCollectionBase.cs
- isolationinterop.cs
- ControlBuilder.cs
- PaintValueEventArgs.cs
- FontStretches.cs
- CollectionsUtil.cs
- _NestedSingleAsyncResult.cs