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
- UntrustedRecipientException.cs
- KnownTypesHelper.cs
- CqlLexer.cs
- UIElement3DAutomationPeer.cs
- HitTestParameters.cs
- TriggerAction.cs
- FlowPanelDesigner.cs
- AnnotationAdorner.cs
- UnsupportedPolicyOptionsException.cs
- CodeTypeDeclarationCollection.cs
- DrawItemEvent.cs
- TailPinnedEventArgs.cs
- PanelStyle.cs
- PanelStyle.cs
- HostingEnvironment.cs
- CodeNamespace.cs
- Rect3DValueSerializer.cs
- TreeNodeCollection.cs
- StackSpiller.Bindings.cs
- Rect3D.cs
- ClaimSet.cs
- DocumentsTrace.cs
- QueryPageSettingsEventArgs.cs
- IImplicitResourceProvider.cs
- FixUp.cs
- CodeCompileUnit.cs
- PersianCalendar.cs
- TypedDatasetGenerator.cs
- ObservableDictionary.cs
- CapabilitiesState.cs
- CodeNamespace.cs
- ConsoleTraceListener.cs
- WebUtility.cs
- DataGridViewCellValueEventArgs.cs
- ThreadStartException.cs
- InternalsVisibleToAttribute.cs
- IntSecurity.cs
- streamingZipPartStream.cs
- DesignerActionTextItem.cs
- Convert.cs
- _ConnectStream.cs
- CollectionViewSource.cs
- BatchParser.cs
- SingleAnimation.cs
- UnauthorizedWebPart.cs
- Configuration.cs
- brushes.cs
- SqlProviderServices.cs
- ArrangedElement.cs
- BindingMemberInfo.cs
- RawMouseInputReport.cs
- InlineCollection.cs
- GetTokenRequest.cs
- OleDbCommandBuilder.cs
- MimePart.cs
- PackUriHelper.cs
- JobDuplex.cs
- ListViewDeletedEventArgs.cs
- GridItemProviderWrapper.cs
- SocketPermission.cs
- HasCopySemanticsAttribute.cs
- KerberosTokenFactoryCredential.cs
- HTMLTagNameToTypeMapper.cs
- ComponentManagerBroker.cs
- CodeTypeReferenceCollection.cs
- EnumerationRangeValidationUtil.cs
- BypassElementCollection.cs
- MatchNoneMessageFilter.cs
- JsonFormatWriterGenerator.cs
- EntitySqlQueryState.cs
- TextParagraphProperties.cs
- SmiSettersStream.cs
- RadioButton.cs
- AsyncPostBackTrigger.cs
- UriExt.cs
- CallId.cs
- TextStore.cs
- DataObjectSettingDataEventArgs.cs
- StateRuntime.cs
- WindowsScrollBarBits.cs
- EllipticalNodeOperations.cs
- OleDbConnection.cs
- CompilationLock.cs
- cache.cs
- FormViewRow.cs
- SqlBulkCopyColumnMapping.cs
- BufferedGraphicsManager.cs
- SqlFunctionAttribute.cs
- XslVisitor.cs
- EncodingDataItem.cs
- ContractListAdapter.cs
- ShellProvider.cs
- FileDialogCustomPlaces.cs
- FontUnit.cs
- DLinqColumnProvider.cs
- CompositionDesigner.cs
- Int16AnimationUsingKeyFrames.cs
- ExecutionEngineException.cs
- HttpPostedFile.cs
- SingleKeyFrameCollection.cs