Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- _SslState.cs
- VirtualStackFrame.cs
- IntSecurity.cs
- DispatcherProcessingDisabled.cs
- DocumentViewerBaseAutomationPeer.cs
- HighlightComponent.cs
- AnyReturnReader.cs
- FigureHelper.cs
- DetailsViewPageEventArgs.cs
- LoginCancelEventArgs.cs
- XmlDownloadManager.cs
- WebBrowserUriTypeConverter.cs
- IriParsingElement.cs
- Stroke.cs
- FrugalList.cs
- TreeNodeCollection.cs
- RequestQueue.cs
- ColumnMapVisitor.cs
- DoubleCollection.cs
- RoutedEventConverter.cs
- AQNBuilder.cs
- JulianCalendar.cs
- EntityDataSourceChangedEventArgs.cs
- CustomError.cs
- XmlSchemaImport.cs
- OwnerDrawPropertyBag.cs
- ConsumerConnectionPoint.cs
- QilXmlWriter.cs
- PeerToPeerException.cs
- PresentationTraceSources.cs
- EditorPartCollection.cs
- StateDesigner.Layouts.cs
- StatusBarPanel.cs
- XmlCDATASection.cs
- DateTimeStorage.cs
- EncryptedType.cs
- SweepDirectionValidation.cs
- EntityDataSourceChangedEventArgs.cs
- DataGridViewCellPaintingEventArgs.cs
- WebPartCatalogAddVerb.cs
- TitleStyle.cs
- SqlProcedureAttribute.cs
- CommonDialog.cs
- XmlReaderSettings.cs
- ListViewPagedDataSource.cs
- Attributes.cs
- WebPartActionVerb.cs
- DefaultMemberAttribute.cs
- DataTemplate.cs
- TimeSpanValidatorAttribute.cs
- GroupDescription.cs
- HtmlElementEventArgs.cs
- InstanceView.cs
- DataGridViewColumnTypeEditor.cs
- Clock.cs
- SafeMILHandleMemoryPressure.cs
- ObjRef.cs
- WindowsFormsEditorServiceHelper.cs
- ContractTypeNameElement.cs
- GregorianCalendarHelper.cs
- Geometry.cs
- GenerateHelper.cs
- ParsedAttributeCollection.cs
- EntityViewGenerationAttribute.cs
- ProviderConnectionPointCollection.cs
- BuildProvider.cs
- UntypedNullExpression.cs
- MissingMemberException.cs
- RIPEMD160Managed.cs
- ContextQuery.cs
- PrintDocument.cs
- DeferredReference.cs
- DataControlFieldCollection.cs
- basecomparevalidator.cs
- DataBindingHandlerAttribute.cs
- SoapSchemaMember.cs
- UserPersonalizationStateInfo.cs
- PointLight.cs
- GeneralTransform3DTo2DTo3D.cs
- HttpModulesSection.cs
- SelectionPatternIdentifiers.cs
- ColorMap.cs
- PerformanceCountersElement.cs
- ProtectedConfiguration.cs
- BidOverLoads.cs
- InvalidOleVariantTypeException.cs
- CompilerTypeWithParams.cs
- SoapInteropTypes.cs
- DropSource.cs
- CAGDesigner.cs
- ViewValidator.cs
- NullableLongSumAggregationOperator.cs
- WebServiceMethodData.cs
- TextEditorContextMenu.cs
- HtmlWindow.cs
- MDIControlStrip.cs
- XmlReaderSettings.cs
- Internal.cs
- Rfc2898DeriveBytes.cs
- DataTable.cs