Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / DefaultValueTypeConverter.cs / 1305376 / 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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlException.cs
- Latin1Encoding.cs
- EntityTemplateUserControl.cs
- SmiRequestExecutor.cs
- TraceContext.cs
- PtsCache.cs
- CodePropertyReferenceExpression.cs
- ResourceManager.cs
- RtfToXamlLexer.cs
- DetailsViewPageEventArgs.cs
- Common.cs
- ReadOnlyDataSourceView.cs
- TypeCodeDomSerializer.cs
- DefaultParameterValueAttribute.cs
- ValidatorCompatibilityHelper.cs
- TreeView.cs
- BoundingRectTracker.cs
- SqlServer2KCompatibilityAnnotation.cs
- XPathNavigator.cs
- relpropertyhelper.cs
- HMACSHA512.cs
- ToolStripGripRenderEventArgs.cs
- RegexWriter.cs
- SmiMetaDataProperty.cs
- FilterableAttribute.cs
- SyntaxCheck.cs
- BrushMappingModeValidation.cs
- LinkArea.cs
- StringDictionaryWithComparer.cs
- Automation.cs
- Deflater.cs
- BamlVersionHeader.cs
- AuthorizationRule.cs
- SizeAnimationBase.cs
- SponsorHelper.cs
- SafeRightsManagementEnvironmentHandle.cs
- ArgumentsParser.cs
- OdbcStatementHandle.cs
- ReflectTypeDescriptionProvider.cs
- documentsequencetextpointer.cs
- DataGridViewCellMouseEventArgs.cs
- DrawingVisual.cs
- XmlLanguageConverter.cs
- ReadOnlyAttribute.cs
- HostedHttpTransportManager.cs
- FormatSettings.cs
- odbcmetadatacolumnnames.cs
- ConnectionConsumerAttribute.cs
- Int16.cs
- VisualTreeHelper.cs
- XmlAutoDetectWriter.cs
- ConnectionManagementElementCollection.cs
- NoneExcludedImageIndexConverter.cs
- ReadOnlyHierarchicalDataSourceView.cs
- XmlSubtreeReader.cs
- HttpEncoder.cs
- DataObject.cs
- ValueExpressions.cs
- CharConverter.cs
- StringCollection.cs
- UnsafeNativeMethods.cs
- Classification.cs
- TogglePatternIdentifiers.cs
- _MultipleConnectAsync.cs
- IconBitmapDecoder.cs
- OleDbCommand.cs
- jithelpers.cs
- PhonemeEventArgs.cs
- Cursor.cs
- ToolboxDataAttribute.cs
- BrowserDefinition.cs
- WorkerRequest.cs
- SQLDateTimeStorage.cs
- PKCS1MaskGenerationMethod.cs
- ActiveXContainer.cs
- WriteableBitmap.cs
- EntityUtil.cs
- DataGridViewTextBoxCell.cs
- InstanceNormalEvent.cs
- MetricEntry.cs
- RawStylusInput.cs
- WindowsAltTab.cs
- GroupDescription.cs
- ZipIOExtraField.cs
- DragDrop.cs
- BCryptNative.cs
- TabletCollection.cs
- ScrollBarRenderer.cs
- TextBoxBase.cs
- PeerResolver.cs
- TextEditorCharacters.cs
- TouchesCapturedWithinProperty.cs
- MetadataUtil.cs
- TableLayoutStyleCollection.cs
- InvalidOperationException.cs
- WebControl.cs
- KerberosTicketHashIdentifierClause.cs
- BitmapMetadata.cs
- XmlWrappingReader.cs
- ClientData.cs