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
- IPAddressCollection.cs
- OleDbPropertySetGuid.cs
- TreeViewAutomationPeer.cs
- HandleCollector.cs
- OneOfConst.cs
- ClientTargetCollection.cs
- DbDataAdapter.cs
- StaticResourceExtension.cs
- BCLDebug.cs
- ArgumentValidation.cs
- ColumnWidthChangingEvent.cs
- Utils.cs
- PositiveTimeSpanValidator.cs
- TextStore.cs
- HMACMD5.cs
- MouseActionConverter.cs
- Serializer.cs
- StaticExtensionConverter.cs
- TextUtf8RawTextWriter.cs
- SoapTypeAttribute.cs
- CommandSet.cs
- BoundColumn.cs
- CatalogPartChrome.cs
- FakeModelItemImpl.cs
- ConfigurationStrings.cs
- InvalidOperationException.cs
- LinearKeyFrames.cs
- CellParagraph.cs
- VisualBrush.cs
- ParameterBuilder.cs
- DataFormats.cs
- SqlMetaData.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- Misc.cs
- ProgressBarBrushConverter.cs
- TraceXPathNavigator.cs
- TimeSpan.cs
- ControlType.cs
- PersianCalendar.cs
- ChannelSinkStacks.cs
- BamlResourceSerializer.cs
- CancellableEnumerable.cs
- QueryHandler.cs
- KeyEventArgs.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- SystemIPGlobalStatistics.cs
- RuntimeWrappedException.cs
- RemoteWebConfigurationHostStream.cs
- StrokeFIndices.cs
- Monitor.cs
- KerberosReceiverSecurityToken.cs
- DesignerEditorPartChrome.cs
- SystemResourceKey.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- CompilerGlobalScopeAttribute.cs
- DataGridViewElement.cs
- InternalMappingException.cs
- PhysicalOps.cs
- CheckBoxBaseAdapter.cs
- DocumentCollection.cs
- SchemaCollectionPreprocessor.cs
- QueryContinueDragEventArgs.cs
- ClientTargetCollection.cs
- PromptStyle.cs
- ProcessStartInfo.cs
- ExpressionConverter.cs
- DayRenderEvent.cs
- CqlGenerator.cs
- RegexMatch.cs
- EndpointIdentityConverter.cs
- ChannelToken.cs
- Merger.cs
- XmlProcessingInstruction.cs
- Verify.cs
- WindowsPrincipal.cs
- DPAPIProtectedConfigurationProvider.cs
- ProviderSettings.cs
- SqlDeflator.cs
- Contracts.cs
- SecurityHelper.cs
- XmlHierarchicalEnumerable.cs
- Pair.cs
- MemberRelationshipService.cs
- UriExt.cs
- Currency.cs
- Listbox.cs
- LinearGradientBrush.cs
- ObfuscationAttribute.cs
- BroadcastEventHelper.cs
- BitmapEffectOutputConnector.cs
- SafeProcessHandle.cs
- FormatterConverter.cs
- VoiceChangeEventArgs.cs
- QuaternionConverter.cs
- DummyDataSource.cs
- KeyValuePair.cs
- CustomAttributeFormatException.cs
- SqlDataSourceAdvancedOptionsForm.cs
- ScriptingSectionGroup.cs
- TreeView.cs