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
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Dispatcher.cs
- UnsafeCollabNativeMethods.cs
- Pointer.cs
- Privilege.cs
- XmlSchemaProviderAttribute.cs
- VisualTarget.cs
- SchemaNames.cs
- PointConverter.cs
- VarRemapper.cs
- BoundField.cs
- ParameterCollectionEditor.cs
- TextTreeExtractElementUndoUnit.cs
- FrameworkElement.cs
- Button.cs
- AnimationStorage.cs
- AffineTransform3D.cs
- OledbConnectionStringbuilder.cs
- XamlBrushSerializer.cs
- CodeCommentStatementCollection.cs
- MetadataSerializer.cs
- PanelDesigner.cs
- SafeThreadHandle.cs
- EDesignUtil.cs
- HttpModuleActionCollection.cs
- DataBoundControl.cs
- CodeArrayIndexerExpression.cs
- SoapAttributeAttribute.cs
- Int16Converter.cs
- DataListCommandEventArgs.cs
- LinearKeyFrames.cs
- UndirectedGraph.cs
- PersonalizationProviderHelper.cs
- DetailsViewDesigner.cs
- WindowsListViewItemCheckBox.cs
- XmlFormatReaderGenerator.cs
- XmlSchemaSimpleContentExtension.cs
- AdornerLayer.cs
- XamlLoadErrorInfo.cs
- NativeActivityMetadata.cs
- SimpleModelProvider.cs
- QuaternionAnimationBase.cs
- ParserOptions.cs
- DataFormat.cs
- ImageSourceConverter.cs
- CodeAttributeDeclaration.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- ComponentTray.cs
- HandleCollector.cs
- MostlySingletonList.cs
- ToolZone.cs
- SerTrace.cs
- TagElement.cs
- TableRow.cs
- ProcessHostServerConfig.cs
- DirectoryNotFoundException.cs
- DefaultDiscoveryServiceExtension.cs
- XsltInput.cs
- BackgroundWorker.cs
- ResourceWriter.cs
- InternalConfigRoot.cs
- ZoneLinkButton.cs
- CompilerGlobalScopeAttribute.cs
- RefreshPropertiesAttribute.cs
- ParentQuery.cs
- DeadCharTextComposition.cs
- ComponentTray.cs
- XmlToDatasetMap.cs
- ImageSourceConverter.cs
- BaseResourcesBuildProvider.cs
- CompilerHelpers.cs
- BevelBitmapEffect.cs
- RangeContentEnumerator.cs
- X509Certificate2.cs
- EventLogInformation.cs
- WebPartsSection.cs
- SqlServices.cs
- TouchDevice.cs
- ButtonFieldBase.cs
- RtfControls.cs
- ServicePoint.cs
- ProfilePropertySettings.cs
- BinaryMessageEncodingElement.cs
- ExceptionHandlerDesigner.cs
- DocumentViewerConstants.cs
- ScriptControl.cs
- Renderer.cs
- DoubleCollection.cs
- SqlException.cs
- GatewayDefinition.cs
- SerialPinChanges.cs
- LoginCancelEventArgs.cs
- SqlRowUpdatingEvent.cs
- VersionUtil.cs
- RecognizedAudio.cs
- DataRelation.cs
- ListView.cs
- ReadOnlyCollectionBase.cs
- LineUtil.cs
- StorageSetMapping.cs
- XsltArgumentList.cs