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
- ColumnBinding.cs
- DesignerProperties.cs
- SqlConnectionString.cs
- ConfigXmlReader.cs
- FrameworkContentElement.cs
- VarRemapper.cs
- ConstantProjectedSlot.cs
- DataGridViewColumn.cs
- FastEncoderWindow.cs
- CodeMemberProperty.cs
- SerializationFieldInfo.cs
- QueryAccessibilityHelpEvent.cs
- Byte.cs
- ProcessActivityTreeOptions.cs
- UpdateCommand.cs
- Buffer.cs
- SqlSupersetValidator.cs
- DataGridViewButtonCell.cs
- MailHeaderInfo.cs
- RegistryPermission.cs
- AlignmentYValidation.cs
- MutexSecurity.cs
- Dispatcher.cs
- PersonalizationProviderHelper.cs
- CodeParameterDeclarationExpression.cs
- ChangePasswordDesigner.cs
- ArrayTypeMismatchException.cs
- ProcessManager.cs
- Triangle.cs
- NonBatchDirectoryCompiler.cs
- ProcessModelInfo.cs
- SqlWorkflowPersistenceService.cs
- QilXmlReader.cs
- ConstraintEnumerator.cs
- HttpModuleActionCollection.cs
- XmlSyndicationContent.cs
- FixedStringLookup.cs
- Lasso.cs
- SafeRightsManagementPubHandle.cs
- EntityParameter.cs
- Point3DAnimation.cs
- PropertyDescriptorCollection.cs
- WebContentFormatHelper.cs
- SetStoryboardSpeedRatio.cs
- UndoUnit.cs
- TdsEnums.cs
- CodeTypeDeclaration.cs
- ViewBase.cs
- UserControlDocumentDesigner.cs
- WebPartHeaderCloseVerb.cs
- MethodBody.cs
- ColorConverter.cs
- DataGridViewImageColumn.cs
- MD5HashHelper.cs
- WmlControlAdapter.cs
- AxWrapperGen.cs
- AuthenticationService.cs
- TreeBuilderXamlTranslator.cs
- ClientSideQueueItem.cs
- SubstitutionList.cs
- ListDictionaryInternal.cs
- PrintPreviewDialog.cs
- DataControlFieldCell.cs
- TextElementCollection.cs
- UnsafeNativeMethods.cs
- ConfigurationStrings.cs
- CollectionBuilder.cs
- Command.cs
- Attributes.cs
- AliasGenerator.cs
- MachineKeySection.cs
- DataControlFieldHeaderCell.cs
- SQLRoleProvider.cs
- CatalogPartChrome.cs
- LocalizedNameDescriptionPair.cs
- ExpressionBinding.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- SqlCacheDependency.cs
- ColumnHeader.cs
- DataGridViewLinkColumn.cs
- mediapermission.cs
- CompilerGeneratedAttribute.cs
- FrameworkElementAutomationPeer.cs
- IdentityManager.cs
- ViewCellSlot.cs
- Oid.cs
- FunctionDetailsReader.cs
- KnownIds.cs
- ContainerActivationHelper.cs
- WinFormsSecurity.cs
- SystemParameters.cs
- ScriptRegistrationManager.cs
- BulletedListDesigner.cs
- AppLevelCompilationSectionCache.cs
- SystemNetHelpers.cs
- Error.cs
- BmpBitmapDecoder.cs
- StrokeNodeOperations.cs
- ToolStripSeparatorRenderEventArgs.cs
- SecurityContextKeyIdentifierClause.cs