Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / DefaultValueTypeConverter.cs / 1305376 / 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
- DesignOnlyAttribute.cs
- ObjectDataProvider.cs
- BufferModeSettings.cs
- PersonalizationState.cs
- DataFormats.cs
- ImmutableAssemblyCacheEntry.cs
- DecimalConstantAttribute.cs
- GradientSpreadMethodValidation.cs
- XD.cs
- BindToObject.cs
- SqlInternalConnectionTds.cs
- PersonalizationAdministration.cs
- RightsManagementInformation.cs
- ToolStripOverflow.cs
- CodeSubDirectory.cs
- WeakHashtable.cs
- ComboBox.cs
- httpserverutility.cs
- StorageEndPropertyMapping.cs
- Missing.cs
- SaveFileDialogDesigner.cs
- FontStretches.cs
- BamlLocalizer.cs
- DrawListViewColumnHeaderEventArgs.cs
- ProfileProvider.cs
- OperationAbortedException.cs
- TableLayoutColumnStyleCollection.cs
- ExceptionHandlers.cs
- RegularExpressionValidator.cs
- DrawingVisualDrawingContext.cs
- MethodSignatureGenerator.cs
- SubMenuStyleCollection.cs
- RTLAwareMessageBox.cs
- UnsafeNativeMethods.cs
- basenumberconverter.cs
- SafeFindHandle.cs
- DeadCharTextComposition.cs
- ReceiveMessageRecord.cs
- RoleManagerModule.cs
- Number.cs
- DataGridViewRow.cs
- DocumentPageViewAutomationPeer.cs
- Literal.cs
- MatrixTransform3D.cs
- ParenthesizePropertyNameAttribute.cs
- Timer.cs
- ReplacementText.cs
- DeclaredTypeElementCollection.cs
- MailBnfHelper.cs
- ProxyHelper.cs
- CompoundFileStreamReference.cs
- ViewValidator.cs
- LinkClickEvent.cs
- AccessDataSourceView.cs
- XPathDescendantIterator.cs
- ConcurrentStack.cs
- CachedBitmap.cs
- GenericIdentity.cs
- Serializer.cs
- CTreeGenerator.cs
- HttpResponseHeader.cs
- OutputCacheProfile.cs
- GeometryModel3D.cs
- SkinBuilder.cs
- TextViewSelectionProcessor.cs
- CompilerParameters.cs
- SyncMethodInvoker.cs
- DeviceContexts.cs
- ComNativeDescriptor.cs
- Array.cs
- TypeLibConverter.cs
- DuplicateWaitObjectException.cs
- XPathNavigatorKeyComparer.cs
- TransactionManager.cs
- ApplicationContext.cs
- WorkflowQueueInfo.cs
- PinnedBufferMemoryStream.cs
- Vector3DKeyFrameCollection.cs
- VisualBrush.cs
- CapiHashAlgorithm.cs
- DockPattern.cs
- Vector3DAnimation.cs
- SoapDocumentServiceAttribute.cs
- FileChangeNotifier.cs
- Typography.cs
- QilGenerator.cs
- ShaderEffect.cs
- ChannelManager.cs
- InvalidOleVariantTypeException.cs
- unsafenativemethodsother.cs
- EntityConnectionStringBuilder.cs
- SectionUpdates.cs
- CompilerTypeWithParams.cs
- NotifyParentPropertyAttribute.cs
- ChooseAction.cs
- PrintPreviewGraphics.cs
- ObjectSet.cs
- StructuredTypeEmitter.cs
- PolyQuadraticBezierSegment.cs
- AsyncPostBackErrorEventArgs.cs