Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ControlBuilderAttribute.cs
- MenuItemStyleCollection.cs
- IntSumAggregationOperator.cs
- XpsSerializationManagerAsync.cs
- ObjectAnimationBase.cs
- XmlUnspecifiedAttribute.cs
- QueryPageSettingsEventArgs.cs
- DataTableCollection.cs
- AccessDataSourceView.cs
- DrawListViewColumnHeaderEventArgs.cs
- DayRenderEvent.cs
- CollectionViewGroupRoot.cs
- SecondaryIndexList.cs
- StringExpressionSet.cs
- SourceFileInfo.cs
- MessageSecurityProtocol.cs
- XPathSingletonIterator.cs
- FunctionDescription.cs
- HMACSHA1.cs
- Psha1DerivedKeyGenerator.cs
- PreviewPageInfo.cs
- SoapClientProtocol.cs
- DataGridViewCellLinkedList.cs
- ErrorFormatter.cs
- HuffModule.cs
- InputScopeConverter.cs
- DynamicActivityXamlReader.cs
- IconEditor.cs
- WebContext.cs
- DbXmlEnabledProviderManifest.cs
- PassportIdentity.cs
- WorkflowInstanceExtensionProvider.cs
- TextDecorationLocationValidation.cs
- Item.cs
- FragmentNavigationEventArgs.cs
- DataGridViewButtonCell.cs
- ThousandthOfEmRealPoints.cs
- ConfigXmlWhitespace.cs
- ExpressionBuilder.cs
- Gdiplus.cs
- VectorCollectionConverter.cs
- FixedSOMTableRow.cs
- SQLRoleProvider.cs
- BufferedGraphics.cs
- XhtmlBasicPhoneCallAdapter.cs
- TemplateKeyConverter.cs
- OracleConnectionString.cs
- ByteConverter.cs
- ThaiBuddhistCalendar.cs
- tooltip.cs
- SmtpCommands.cs
- BinaryMethodMessage.cs
- SerializerProvider.cs
- ListBindingConverter.cs
- SmiConnection.cs
- httpserverutility.cs
- StringBuilder.cs
- GlyphInfoList.cs
- SafeLocalAllocation.cs
- TemplateComponentConnector.cs
- BinaryFormatterWriter.cs
- PropertyOverridesDialog.cs
- ListBindableAttribute.cs
- MessageQueue.cs
- AbsoluteQuery.cs
- ProfileSettings.cs
- ProfilePropertySettings.cs
- CellRelation.cs
- SafeSecurityHandles.cs
- JoinElimination.cs
- OptimizedTemplateContentHelper.cs
- ZipIOFileItemStream.cs
- WebPartMenuStyle.cs
- PropertyPathWorker.cs
- EntityDataReader.cs
- OutputCacheProviderCollection.cs
- NativeMethods.cs
- BigInt.cs
- ViewGenerator.cs
- TextSelectionProcessor.cs
- URLIdentityPermission.cs
- IQueryable.cs
- MissingMemberException.cs
- IgnorePropertiesAttribute.cs
- DesignerOptions.cs
- RoleExceptions.cs
- PeerFlooder.cs
- LookupNode.cs
- ListView.cs
- CompilerLocalReference.cs
- SolidBrush.cs
- ObjectFullSpanRewriter.cs
- UnionCodeGroup.cs
- ScriptingRoleServiceSection.cs
- DataGridViewCellCollection.cs
- Single.cs
- InvalidDataException.cs
- PropertyIdentifier.cs
- ReaderWriterLockSlim.cs
- StyleXamlParser.cs