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
- DirectoryObjectSecurity.cs
- WindowsStreamSecurityUpgradeProvider.cs
- LinqDataSourceInsertEventArgs.cs
- TreeViewEvent.cs
- QilSortKey.cs
- DesignTimeTemplateParser.cs
- Int64Animation.cs
- DbUpdateCommandTree.cs
- HostExecutionContextManager.cs
- PerformanceCounterManager.cs
- DeclarationUpdate.cs
- StyleReferenceConverter.cs
- MenuItemBinding.cs
- AsymmetricSignatureFormatter.cs
- WindowHideOrCloseTracker.cs
- XmlSchemaAppInfo.cs
- TextServicesProperty.cs
- KerberosSecurityTokenProvider.cs
- FloatUtil.cs
- CloseSequenceResponse.cs
- FixedBufferAttribute.cs
- StatusBarAutomationPeer.cs
- Polyline.cs
- XmlCharType.cs
- Attributes.cs
- EntitySqlException.cs
- ApplicationSecurityManager.cs
- TreeNodeSelectionProcessor.cs
- OrderByExpression.cs
- TCEAdapterGenerator.cs
- ParameterToken.cs
- SiblingIterators.cs
- FixedDocumentSequencePaginator.cs
- SelectionItemPattern.cs
- StateWorkerRequest.cs
- PropertyChangingEventArgs.cs
- GridViewCellAutomationPeer.cs
- Mappings.cs
- DetailsViewPagerRow.cs
- XPathNodeInfoAtom.cs
- TypeDescriptionProviderAttribute.cs
- Utils.cs
- BinaryFormatter.cs
- PathFigure.cs
- UriParserTemplates.cs
- TypeTypeConverter.cs
- HttpFileCollection.cs
- MainMenu.cs
- TypeConverters.cs
- TemplateXamlParser.cs
- InkCanvasFeedbackAdorner.cs
- BamlReader.cs
- AccessedThroughPropertyAttribute.cs
- XPathNodeList.cs
- autovalidator.cs
- Solver.cs
- TagPrefixAttribute.cs
- AuthenticationService.cs
- FormParameter.cs
- EncodingFallbackAwareXmlTextWriter.cs
- IdentityReference.cs
- DeleteMemberBinder.cs
- GeneralTransform3DTo2D.cs
- TypeUtils.cs
- OracleDataReader.cs
- ViewGenResults.cs
- RealProxy.cs
- BridgeDataReader.cs
- KnownColorTable.cs
- Compiler.cs
- CatalogZoneDesigner.cs
- ToolboxBitmapAttribute.cs
- FamilyTypeface.cs
- DataGridViewImageColumn.cs
- HotCommands.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- COM2PropertyDescriptor.cs
- TransactedBatchingElement.cs
- contentDescriptor.cs
- GlyphInfoList.cs
- AutomationElement.cs
- WebEvents.cs
- ApplicationHost.cs
- ComponentEvent.cs
- ResourceDisplayNameAttribute.cs
- FloatMinMaxAggregationOperator.cs
- NamedPipeHostedTransportConfiguration.cs
- SQLBoolean.cs
- SimpleExpression.cs
- ObjectHandle.cs
- MultilineStringConverter.cs
- NativeWindow.cs
- CachedPathData.cs
- MenuCommand.cs
- Context.cs
- PassportAuthentication.cs
- PrivateFontCollection.cs
- XmlArrayItemAttribute.cs
- NullToBooleanConverter.cs
- ValueQuery.cs