Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- basecomparevalidator.cs
- RuleSettings.cs
- XmlValueConverter.cs
- FixedSOMTableRow.cs
- DesignerEditorPartChrome.cs
- TemplateBindingExpression.cs
- DataRow.cs
- HebrewNumber.cs
- CultureInfoConverter.cs
- EventHandlersStore.cs
- MdiWindowListItemConverter.cs
- Misc.cs
- InternalConfigHost.cs
- RequestCacheManager.cs
- FontWeightConverter.cs
- TraceLevelStore.cs
- WebPartConnectionsCancelEventArgs.cs
- XPathAxisIterator.cs
- DoubleLinkListEnumerator.cs
- CryptoConfig.cs
- CheckPair.cs
- SemanticTag.cs
- XmlNamespaceDeclarationsAttribute.cs
- TimersDescriptionAttribute.cs
- TableCell.cs
- OracleColumn.cs
- ThreadStateException.cs
- OrderByQueryOptionExpression.cs
- ShapeTypeface.cs
- ContentPropertyAttribute.cs
- ConfigurationErrorsException.cs
- XXXOnTypeBuilderInstantiation.cs
- __Filters.cs
- TypeViewSchema.cs
- CatalogPartCollection.cs
- TextTreeUndo.cs
- EDesignUtil.cs
- SpeechSynthesizer.cs
- TransportationConfigurationTypeInstallComponent.cs
- EntityDataSourceDesignerHelper.cs
- Annotation.cs
- StyleCollectionEditor.cs
- NativeMethods.cs
- RequestCacheValidator.cs
- Version.cs
- hresults.cs
- PersonalizationState.cs
- MultilineStringEditor.cs
- ToolStripDesignerAvailabilityAttribute.cs
- TransformGroup.cs
- UndoManager.cs
- BindableAttribute.cs
- Normalization.cs
- ContextMenuStrip.cs
- EntityParameterCollection.cs
- AutoGeneratedField.cs
- ListViewGroup.cs
- BufferedOutputAsyncStream.cs
- DialogWindow.cs
- ReaderWriterLockWrapper.cs
- MetadataFile.cs
- SelectQueryOperator.cs
- SqlRetyper.cs
- FixedSOMGroup.cs
- PropagatorResult.cs
- PieceDirectory.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- FlowNode.cs
- TextElementAutomationPeer.cs
- PolicyValidationException.cs
- HttpHandler.cs
- ControlBindingsCollection.cs
- SqlDataReader.cs
- ReferentialConstraint.cs
- HMACSHA1.cs
- Crc32Helper.cs
- DataGridViewRowPostPaintEventArgs.cs
- SqlInternalConnection.cs
- ExternalFile.cs
- XmlHierarchicalDataSourceView.cs
- RSAOAEPKeyExchangeFormatter.cs
- IDQuery.cs
- ParameterCollection.cs
- CompositionTarget.cs
- WindowsSecurityTokenAuthenticator.cs
- BitSet.cs
- WindowsTokenRoleProvider.cs
- Util.cs
- SqlDataSourceCache.cs
- DesignerLinkAdapter.cs
- ConnectionStringsSection.cs
- WebColorConverter.cs
- TaskFormBase.cs
- HtmlContainerControl.cs
- keycontainerpermission.cs
- DataServiceQuery.cs
- SystemKeyConverter.cs
- HeaderUtility.cs
- TemplateKey.cs
- DynamicMethod.cs