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
- DesignerSerializationVisibilityAttribute.cs
- ScrollBarAutomationPeer.cs
- OutputScopeManager.cs
- DataGridViewComboBoxColumn.cs
- WebBrowserSiteBase.cs
- DataGridViewCellPaintingEventArgs.cs
- XsltContext.cs
- SeekStoryboard.cs
- ControlPaint.cs
- Paragraph.cs
- SQLSingle.cs
- XmlSchemaInfo.cs
- XmlIncludeAttribute.cs
- StoryFragments.cs
- thaishape.cs
- pingexception.cs
- ImageSourceConverter.cs
- BitmapDecoder.cs
- QilSortKey.cs
- UnaryExpression.cs
- CustomSignedXml.cs
- Latin1Encoding.cs
- Rect.cs
- PropertyMap.cs
- XmlLanguageConverter.cs
- HandleCollector.cs
- SendMailErrorEventArgs.cs
- VarRefManager.cs
- BinHexEncoder.cs
- SiteMapHierarchicalDataSourceView.cs
- AgileSafeNativeMemoryHandle.cs
- ScriptMethodAttribute.cs
- TextTreeInsertElementUndoUnit.cs
- TrackingDataItemValue.cs
- TextElement.cs
- KeyedPriorityQueue.cs
- FileController.cs
- Material.cs
- HMAC.cs
- DatatypeImplementation.cs
- ErrorFormatter.cs
- ServiceThrottlingBehavior.cs
- PathSegment.cs
- WebUtil.cs
- WindowsFormsHostAutomationPeer.cs
- BoundPropertyEntry.cs
- ObjectView.cs
- DataGridViewImageCell.cs
- ColumnWidthChangingEvent.cs
- ModulesEntry.cs
- SiteMembershipCondition.cs
- ResXBuildProvider.cs
- DynamicControl.cs
- UniqueConstraint.cs
- StringAnimationUsingKeyFrames.cs
- FillRuleValidation.cs
- CacheRequest.cs
- DictionaryEntry.cs
- ClientSettingsSection.cs
- PlainXmlSerializer.cs
- DoubleUtil.cs
- WinFormsUtils.cs
- CompressEmulationStream.cs
- LinkLabel.cs
- ConfigViewGenerator.cs
- MergeFilterQuery.cs
- ObjRef.cs
- IndexedWhereQueryOperator.cs
- GPStream.cs
- SplitterEvent.cs
- ProbeDuplex11AsyncResult.cs
- SaveFileDialog.cs
- FtpCachePolicyElement.cs
- GradientBrush.cs
- SmtpDateTime.cs
- EFTableProvider.cs
- ServiceDescriptionData.cs
- IListConverters.cs
- BasicAsyncResult.cs
- Visual3DCollection.cs
- ControlUtil.cs
- MouseBinding.cs
- LookupNode.cs
- ImpersonateTokenRef.cs
- DtcInterfaces.cs
- QilReference.cs
- SystemResourceHost.cs
- ArgIterator.cs
- SimpleApplicationHost.cs
- SQLInt16.cs
- AnnotationAuthorChangedEventArgs.cs
- RegexRunnerFactory.cs
- DBSqlParserTable.cs
- WorkflowTraceTransfer.cs
- WorkflowOperationAsyncResult.cs
- Point3DAnimationUsingKeyFrames.cs
- ToolTip.cs
- Helper.cs
- RequestSecurityTokenForGetBrowserToken.cs
- safex509handles.cs