Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- BamlLocalizer.cs
- XmlSchemaCollection.cs
- CharConverter.cs
- FolderBrowserDialog.cs
- CommandHelper.cs
- InstanceValue.cs
- ArgIterator.cs
- CreateRefExpr.cs
- PanelDesigner.cs
- ForeignKeyConstraint.cs
- InputProviderSite.cs
- FieldNameLookup.cs
- ByteStream.cs
- ParseHttpDate.cs
- WizardStepBase.cs
- SafeSystemMetrics.cs
- ReadOnlyDictionary.cs
- SoapHeaderException.cs
- CompilerScope.Storage.cs
- CardSpacePolicyElement.cs
- ListQueryResults.cs
- WebPartHeaderCloseVerb.cs
- ViewStateAttachedPropertyFeature.cs
- StrokeNodeData.cs
- SafeReadContext.cs
- XamlTemplateSerializer.cs
- Axis.cs
- DbTransaction.cs
- DataGridViewComboBoxCell.cs
- WindowsIdentity.cs
- StyleSheet.cs
- Compress.cs
- EditorPartChrome.cs
- WebResponse.cs
- ToolStripCodeDomSerializer.cs
- ItemMap.cs
- TypeTypeConverter.cs
- UnsafePeerToPeerMethods.cs
- DbConnectionPoolIdentity.cs
- LoginName.cs
- COM2TypeInfoProcessor.cs
- XmlSchemaAnnotated.cs
- SystemIPInterfaceStatistics.cs
- StateItem.cs
- ApplicationTrust.cs
- ReadOnlyAttribute.cs
- WebServiceHandler.cs
- SqlUtil.cs
- CharConverter.cs
- SapiAttributeParser.cs
- InvalidEnumArgumentException.cs
- BufferedStream.cs
- PackageRelationship.cs
- InteropAutomationProvider.cs
- ContextMenu.cs
- Journal.cs
- rsa.cs
- MethodAccessException.cs
- SHA512CryptoServiceProvider.cs
- ConfigurationPropertyCollection.cs
- MissingManifestResourceException.cs
- EUCJPEncoding.cs
- GeneralTransformGroup.cs
- XPathMessageFilter.cs
- ProcessThreadCollection.cs
- NullableBoolConverter.cs
- CellCreator.cs
- FixedSOMPageElement.cs
- DetailsViewModeEventArgs.cs
- DrawingState.cs
- UxThemeWrapper.cs
- BitmapEffectRenderDataResource.cs
- WebCategoryAttribute.cs
- autovalidator.cs
- AttachedProperty.cs
- AggregateNode.cs
- XNodeSchemaApplier.cs
- ApplyHostConfigurationBehavior.cs
- ProfileManager.cs
- OlePropertyStructs.cs
- ExpandoClass.cs
- sqlser.cs
- Opcode.cs
- InfoCardSymmetricAlgorithm.cs
- HashAlgorithm.cs
- ImplicitInputBrush.cs
- GridViewPageEventArgs.cs
- ByteStreamGeometryContext.cs
- CqlBlock.cs
- PhoneCall.cs
- ApplicationManager.cs
- System.Data.OracleClient_BID.cs
- CallbackException.cs
- AsyncOperation.cs
- SchemaTableOptionalColumn.cs
- ProcessStartInfo.cs
- BrowsableAttribute.cs
- RemotingException.cs
- CdpEqualityComparer.cs
- NativeMethods.cs