Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- ClientUtils.cs
- SQLBoolean.cs
- TextEditorSelection.cs
- QueryComponents.cs
- FlowDocument.cs
- NavigatingCancelEventArgs.cs
- EntityEntry.cs
- MouseGestureValueSerializer.cs
- PartialCachingAttribute.cs
- PaperSource.cs
- SqlDeflator.cs
- RadioButtonList.cs
- ImageKeyConverter.cs
- TextControlDesigner.cs
- DataBoundControl.cs
- precedingquery.cs
- DefaultBindingPropertyAttribute.cs
- ItemContainerGenerator.cs
- RestClientProxyHandler.cs
- IdnMapping.cs
- DataProtectionSecurityStateEncoder.cs
- PersonalizationProviderCollection.cs
- SignedInfo.cs
- NavigationProperty.cs
- AdRotatorDesigner.cs
- DynamicRendererThreadManager.cs
- LinkedResource.cs
- _DigestClient.cs
- AppDomainShutdownMonitor.cs
- MimePart.cs
- PnrpPeerResolver.cs
- UserControlAutomationPeer.cs
- MailBnfHelper.cs
- LayoutDump.cs
- _StreamFramer.cs
- JavaScriptString.cs
- Decoder.cs
- ExpressionDumper.cs
- PropertyItemInternal.cs
- EventWaitHandle.cs
- GC.cs
- WCFBuildProvider.cs
- WebHttpBinding.cs
- EncoderNLS.cs
- AutomationPropertyInfo.cs
- ObjectConverter.cs
- TemplateField.cs
- RecognitionResult.cs
- ChtmlCalendarAdapter.cs
- RequestStatusBarUpdateEventArgs.cs
- SubMenuStyle.cs
- FunctionDescription.cs
- HttpResponseBase.cs
- SessionMode.cs
- UniqueIdentifierService.cs
- OletxTransactionManager.cs
- MdImport.cs
- ProjectedSlot.cs
- PersistenceTypeAttribute.cs
- CallbackDebugBehavior.cs
- NumericExpr.cs
- DispatcherProcessingDisabled.cs
- CategoryGridEntry.cs
- DataGridItem.cs
- AuthenticationService.cs
- DataGridViewRowEventArgs.cs
- CryptoStream.cs
- PermissionToken.cs
- printdlgexmarshaler.cs
- Quaternion.cs
- WrappingXamlSchemaContext.cs
- AmbientValueAttribute.cs
- PropertiesTab.cs
- ConversionContext.cs
- SemanticTag.cs
- ConfigurationValue.cs
- ITreeGenerator.cs
- UnsafeNativeMethods.cs
- FloatUtil.cs
- IconHelper.cs
- ColorConverter.cs
- DesignerAttributeInfo.cs
- BuildManager.cs
- PeerUnsafeNativeMethods.cs
- dbenumerator.cs
- TextRangeEditLists.cs
- DataColumnChangeEvent.cs
- SafePEFileHandle.cs
- DataGridComponentEditor.cs
- BaseDataList.cs
- CircleHotSpot.cs
- TextBoxBaseDesigner.cs
- RuleProcessor.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- HttpListenerRequestUriBuilder.cs
- ArraySubsetEnumerator.cs
- TextRunCacheImp.cs
- DoubleLink.cs
- PartialList.cs
- DashStyle.cs