Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / DefaultValueTypeConverter.cs / 1305376 / 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
- HtmlLink.cs
- securitycriticaldataformultiplegetandset.cs
- SafeProcessHandle.cs
- DefinitionBase.cs
- LOSFormatter.cs
- File.cs
- Maps.cs
- XmlSchemaCompilationSettings.cs
- FastEncoderWindow.cs
- MarshalByRefObject.cs
- ListItemParagraph.cs
- DataGridHelper.cs
- GridViewDesigner.cs
- StreamWriter.cs
- ContextMenuService.cs
- XmlCompatibilityReader.cs
- GeneralTransform2DTo3DTo2D.cs
- WebPartUserCapability.cs
- CodeCatchClauseCollection.cs
- HtmlAnchor.cs
- SimpleHandlerFactory.cs
- AncestorChangedEventArgs.cs
- DataStreamFromComStream.cs
- LinkClickEvent.cs
- _UriSyntax.cs
- GridViewDeleteEventArgs.cs
- querybuilder.cs
- HMACMD5.cs
- RegionInfo.cs
- SocketInformation.cs
- QuestionEventArgs.cs
- MultiSelectRootGridEntry.cs
- FactoryGenerator.cs
- ErrorWebPart.cs
- BridgeDataReader.cs
- QilFunction.cs
- SqlBuilder.cs
- SByteStorage.cs
- SqlConnectionStringBuilder.cs
- ObjectDataSourceDisposingEventArgs.cs
- QueuePathEditor.cs
- RectAnimationBase.cs
- SignatureDescription.cs
- TimeSpanMinutesConverter.cs
- ObjectDataSourceMethodEventArgs.cs
- ResourceDescriptionAttribute.cs
- EditCommandColumn.cs
- NavigationWindowAutomationPeer.cs
- WizardPanelChangingEventArgs.cs
- AddInDeploymentState.cs
- X509CertificateValidationMode.cs
- HideDisabledControlAdapter.cs
- TdsEnums.cs
- WebBrowserNavigatedEventHandler.cs
- ErrorProvider.cs
- PrintingPermission.cs
- DataViewSetting.cs
- LiteralDesigner.cs
- DBCommandBuilder.cs
- VerticalAlignConverter.cs
- AttributeQuery.cs
- TransformGroup.cs
- TextBox.cs
- DataGridCellsPanel.cs
- DecoderFallback.cs
- Label.cs
- AsyncStreamReader.cs
- ProtectedConfiguration.cs
- XamlGridLengthSerializer.cs
- RawAppCommandInputReport.cs
- RegularExpressionValidator.cs
- EmptyElement.cs
- CreateUserWizardAutoFormat.cs
- FilterElement.cs
- ZipIOExtraField.cs
- HostingPreferredMapPath.cs
- SimpleModelProvider.cs
- CatalogUtil.cs
- OleDbConnectionFactory.cs
- ConfigurationPropertyAttribute.cs
- InputReferenceExpression.cs
- GuidConverter.cs
- ExpressionEditorAttribute.cs
- DebugView.cs
- DBConnectionString.cs
- GroupQuery.cs
- Function.cs
- DetailsViewDeleteEventArgs.cs
- MembershipPasswordException.cs
- IdentityReference.cs
- StringCollectionMarkupSerializer.cs
- XmlTypeAttribute.cs
- WebBrowserSiteBase.cs
- DataComponentNameHandler.cs
- JournalEntry.cs
- ACE.cs
- TextTreeTextElementNode.cs
- MediaSystem.cs
- ButtonColumn.cs
- WindowsImpersonationContext.cs