Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- LineBreakRecord.cs
- TypeDescriptionProviderAttribute.cs
- TextTreeNode.cs
- DateTimeParse.cs
- CharacterMetricsDictionary.cs
- TimerEventSubscriptionCollection.cs
- ClickablePoint.cs
- UserPreferenceChangedEventArgs.cs
- SQLGuid.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- DurationConverter.cs
- PeerOutputChannel.cs
- ExceptionUtility.cs
- xml.cs
- ClientScriptItemCollection.cs
- DataRowView.cs
- ExternalCalls.cs
- loginstatus.cs
- versioninfo.cs
- RuntimeArgumentHandle.cs
- SourceElementsCollection.cs
- SimpleBitVector32.cs
- Bezier.cs
- WebScriptMetadataFormatter.cs
- FormViewModeEventArgs.cs
- ISAPIWorkerRequest.cs
- ConsoleTraceListener.cs
- Cursor.cs
- DescendentsWalkerBase.cs
- PropertyChangeTracker.cs
- SymbolMethod.cs
- GB18030Encoding.cs
- IgnoreSectionHandler.cs
- HyperlinkAutomationPeer.cs
- EnumMember.cs
- XmlSerializationGeneratedCode.cs
- TabPage.cs
- DataBindEngine.cs
- ProxyHwnd.cs
- PersonalizationAdministration.cs
- Wizard.cs
- XmlChildEnumerator.cs
- AccessedThroughPropertyAttribute.cs
- ComPlusThreadInitializer.cs
- MarkupExtensionParser.cs
- PropertySegmentSerializationProvider.cs
- ViewLoader.cs
- PropertyMappingExceptionEventArgs.cs
- DataProtection.cs
- BindingsCollection.cs
- DataFieldCollectionEditor.cs
- NotCondition.cs
- CryptoStream.cs
- CompilationLock.cs
- ProtocolsConfigurationEntry.cs
- oledbconnectionstring.cs
- HtmlHistory.cs
- BevelBitmapEffect.cs
- Interop.cs
- MsmqIntegrationChannelListener.cs
- HwndTarget.cs
- KeyValuePairs.cs
- SatelliteContractVersionAttribute.cs
- x509utils.cs
- GroupItemAutomationPeer.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- XPathNodePointer.cs
- DefaultClaimSet.cs
- EmptyEnumerator.cs
- MatrixUtil.cs
- TableCellCollection.cs
- PageEventArgs.cs
- XslException.cs
- SourceChangedEventArgs.cs
- DataTable.cs
- TextRunCacheImp.cs
- ValidationErrorInfo.cs
- HtmlEmptyTagControlBuilder.cs
- CachedTypeface.cs
- ChangeTracker.cs
- XmlExpressionDumper.cs
- MexTcpBindingCollectionElement.cs
- CompensationDesigner.cs
- EventsTab.cs
- InplaceBitmapMetadataWriter.cs
- SchemaNotation.cs
- LassoHelper.cs
- SpecialNameAttribute.cs
- FixedDSBuilder.cs
- SoundPlayerAction.cs
- _OSSOCK.cs
- MouseBinding.cs
- WMIGenerator.cs
- BlurEffect.cs
- LassoSelectionBehavior.cs
- StringDictionary.cs
- NominalTypeEliminator.cs
- Canvas.cs
- CharAnimationUsingKeyFrames.cs
- UnauthorizedWebPart.cs