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
- AddToCollection.cs
- ReadingWritingEntityEventArgs.cs
- NameTable.cs
- TypeSystem.cs
- BufferedGraphicsManager.cs
- TextTreeNode.cs
- SqlDataSourceConfigureSortForm.cs
- ContentPlaceHolder.cs
- XmlNamespaceManager.cs
- DrawingGroup.cs
- TableTextElementCollectionInternal.cs
- MessageQueueEnumerator.cs
- TransportBindingElementImporter.cs
- MsmqBindingBase.cs
- SymDocumentType.cs
- NativeCompoundFileAPIs.cs
- ListViewInsertionMark.cs
- GradientBrush.cs
- IDQuery.cs
- ClientSideProviderDescription.cs
- SqlAliasesReferenced.cs
- PackWebRequestFactory.cs
- TextModifierScope.cs
- XmlSchemaImporter.cs
- Parallel.cs
- DrawingServices.cs
- MatrixAnimationUsingPath.cs
- Fault.cs
- Triangle.cs
- PropertyDescriptorCollection.cs
- SqlDependencyUtils.cs
- RadioButtonList.cs
- AssociatedControlConverter.cs
- SqlDataSourceFilteringEventArgs.cs
- KoreanCalendar.cs
- RelationshipNavigation.cs
- StringArrayConverter.cs
- ClickablePoint.cs
- COAUTHINFO.cs
- WebServiceData.cs
- FixedPageStructure.cs
- ParallelTimeline.cs
- LifetimeManager.cs
- SwitchAttribute.cs
- RouteCollection.cs
- AxHost.cs
- TrustLevelCollection.cs
- QueryStoreStatusRequest.cs
- StylusPointPropertyId.cs
- HierarchicalDataTemplate.cs
- TextBox.cs
- ObjectHandle.cs
- TextSerializer.cs
- ColorMatrix.cs
- DataContractSerializer.cs
- GradientSpreadMethodValidation.cs
- TableRow.cs
- PackUriHelper.cs
- XomlCompilerParameters.cs
- COM2TypeInfoProcessor.cs
- MetadataExchangeBindings.cs
- XamlSerializerUtil.cs
- FaultReasonText.cs
- PtsHelper.cs
- WindowsPrincipal.cs
- ChineseLunisolarCalendar.cs
- DataSourceXmlSubItemAttribute.cs
- DaylightTime.cs
- GroupBoxDesigner.cs
- CqlLexerHelpers.cs
- CustomCategoryAttribute.cs
- ActivityCodeDomSerializationManager.cs
- SourceFileBuildProvider.cs
- DataGridTablesFactory.cs
- BoundingRectTracker.cs
- CqlBlock.cs
- RequestUriProcessor.cs
- UserNameSecurityToken.cs
- PhoneCall.cs
- RowType.cs
- SupportingTokenAuthenticatorSpecification.cs
- ResponseStream.cs
- EdmProviderManifest.cs
- InternalCache.cs
- RealizationContext.cs
- ByteStreamMessageEncoder.cs
- Avt.cs
- GAC.cs
- SiteMapSection.cs
- ReaderWriterLockWrapper.cs
- UrlPath.cs
- ImageSource.cs
- HtmlInputImage.cs
- NextPreviousPagerField.cs
- PageMediaSize.cs
- DataControlFieldCollection.cs
- SessionState.cs
- DefaultTextStoreTextComposition.cs
- BufferModeSettings.cs
- CompilerResults.cs