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
- SystemNetworkInterface.cs
- HybridDictionary.cs
- CopyCodeAction.cs
- PenContext.cs
- columnmapkeybuilder.cs
- Visual3D.cs
- TabControl.cs
- MruCache.cs
- PropertyValueUIItem.cs
- RemoteWebConfigurationHostServer.cs
- ToolStripTemplateNode.cs
- PersonalizationProvider.cs
- StylesEditorDialog.cs
- DataGridPageChangedEventArgs.cs
- UnsupportedPolicyOptionsException.cs
- MetafileHeaderWmf.cs
- EntityContainerAssociationSetEnd.cs
- ManagementObjectCollection.cs
- DataGridComboBoxColumn.cs
- TextProperties.cs
- Calendar.cs
- WindowsToolbarItemAsMenuItem.cs
- RawStylusSystemGestureInputReport.cs
- Restrictions.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- XmlSubtreeReader.cs
- SimpleType.cs
- PerfService.cs
- HitTestResult.cs
- QilVisitor.cs
- EventProxy.cs
- SpeechAudioFormatInfo.cs
- NameValueFileSectionHandler.cs
- Enlistment.cs
- CompleteWizardStep.cs
- MarginCollapsingState.cs
- HtmlProps.cs
- Error.cs
- Thread.cs
- IssuanceLicense.cs
- DataKey.cs
- ViewPort3D.cs
- SecurityHeaderElementInferenceEngine.cs
- GeometryConverter.cs
- SqlStatistics.cs
- DependencyPropertyKind.cs
- ParameterBuilder.cs
- ConsoleTraceListener.cs
- TextBreakpoint.cs
- SourceFileInfo.cs
- SchemaImporter.cs
- SparseMemoryStream.cs
- Codec.cs
- PartitionedStream.cs
- NamedPipeActivation.cs
- ExpressionCopier.cs
- CompModSwitches.cs
- ErrorStyle.cs
- Maps.cs
- SR.cs
- FieldMetadata.cs
- GPPOINT.cs
- HwndStylusInputProvider.cs
- SmtpSection.cs
- SqlHelper.cs
- EventSourceCreationData.cs
- MatrixTransform3D.cs
- ConfigurationManager.cs
- WebServiceHostFactory.cs
- CFStream.cs
- PerformanceCountersElement.cs
- ColumnTypeConverter.cs
- CompressedStack.cs
- _AutoWebProxyScriptWrapper.cs
- SHA512.cs
- StreamWriter.cs
- PropertyNames.cs
- _ListenerResponseStream.cs
- ConfigurationManagerInternal.cs
- LinqTreeNodeEvaluator.cs
- DeferredReference.cs
- ThemeDictionaryExtension.cs
- MemberExpression.cs
- BufferedMessageData.cs
- WindowsStatic.cs
- OdbcTransaction.cs
- QueryOperationResponseOfT.cs
- ReadOnlyDictionary.cs
- SyndicationLink.cs
- CssStyleCollection.cs
- Thickness.cs
- ShellProvider.cs
- DictationGrammar.cs
- SecurityIdentifierConverter.cs
- SiteMapHierarchicalDataSourceView.cs
- UniqueIdentifierService.cs
- CaseInsensitiveOrdinalStringComparer.cs
- CultureNotFoundException.cs
- Logging.cs
- HttpCacheVary.cs