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
- MruCache.cs
- FixedSOMLineCollection.cs
- NativeWindow.cs
- BackgroundWorker.cs
- CancelRequestedRecord.cs
- ACE.cs
- SystemWebCachingSectionGroup.cs
- WebPartZoneBase.cs
- CharEntityEncoderFallback.cs
- UnrecognizedAssertionsBindingElement.cs
- ObjectStateEntryDbDataRecord.cs
- LayoutManager.cs
- WebPartTransformer.cs
- HtmlUtf8RawTextWriter.cs
- LoginUtil.cs
- TimersDescriptionAttribute.cs
- UriTemplateClientFormatter.cs
- PackageStore.cs
- ServiceMetadataBehavior.cs
- ListSortDescription.cs
- ClusterSafeNativeMethods.cs
- MissingSatelliteAssemblyException.cs
- AssemblyAttributes.cs
- Constraint.cs
- ApplicationGesture.cs
- SelectedDatesCollection.cs
- Debug.cs
- MenuRendererStandards.cs
- MediaElementAutomationPeer.cs
- BitmapFrameEncode.cs
- ToolStripDropDownClosingEventArgs.cs
- SubMenuStyle.cs
- SqlCommandAsyncResult.cs
- CommunicationObject.cs
- WebSysDisplayNameAttribute.cs
- XmlLanguage.cs
- TransformFinalBlockRequest.cs
- EntitySetDataBindingList.cs
- DataSourceExpressionCollection.cs
- HttpConfigurationSystem.cs
- XmlSchemaAnnotated.cs
- SafeMemoryMappedViewHandle.cs
- DataTableReader.cs
- CharAnimationBase.cs
- OleDbSchemaGuid.cs
- WithParamAction.cs
- objectquery_tresulttype.cs
- ReversePositionQuery.cs
- ListViewItem.cs
- ToolStripRenderEventArgs.cs
- BooleanAnimationBase.cs
- DocobjHost.cs
- DataGridColumnCollectionEditor.cs
- AssertUtility.cs
- BitmapEffectGeneralTransform.cs
- ExpressionBindingCollection.cs
- DataQuery.cs
- _LazyAsyncResult.cs
- StyleCollectionEditor.cs
- DiscoveryClientChannelBase.cs
- UrlMappingCollection.cs
- DeferredElementTreeState.cs
- Debug.cs
- DataGridViewTopRowAccessibleObject.cs
- TransformCryptoHandle.cs
- EpmSyndicationContentSerializer.cs
- DeploymentSectionCache.cs
- MULTI_QI.cs
- EntityException.cs
- ExceptionValidationRule.cs
- SqlInternalConnectionSmi.cs
- XmlException.cs
- IncomingWebRequestContext.cs
- PropertyChangeTracker.cs
- ClientSponsor.cs
- ProcessManager.cs
- StringArrayEditor.cs
- SimpleHandlerBuildProvider.cs
- SingleSelectRootGridEntry.cs
- FrameworkElementAutomationPeer.cs
- UnsafeNativeMethodsTablet.cs
- StoragePropertyMapping.cs
- StringAnimationBase.cs
- BufferedGraphicsManager.cs
- UpdateCompiler.cs
- PresentationAppDomainManager.cs
- CustomTrackingRecord.cs
- SpotLight.cs
- Matrix3DConverter.cs
- CachedBitmap.cs
- HtmlHead.cs
- MobileControlsSectionHelper.cs
- VisualTreeUtils.cs
- filewebresponse.cs
- OletxEnlistment.cs
- SendActivityEventArgs.cs
- Repeater.cs
- VisualStyleInformation.cs
- ViewPort3D.cs
- FixedSOMTableRow.cs