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
- UserPersonalizationStateInfo.cs
- PropertyTab.cs
- SystemIPAddressInformation.cs
- UserMapPath.cs
- HttpModuleActionCollection.cs
- ResourceWriter.cs
- ByteStorage.cs
- MarshalByValueComponent.cs
- COM2Enum.cs
- DateTimeFormatInfoScanner.cs
- Validator.cs
- TemplateFactory.cs
- ColorConverter.cs
- SafeNativeMethods.cs
- ToolboxComponentsCreatedEventArgs.cs
- WebPartManager.cs
- CookieParameter.cs
- FontCollection.cs
- ObjectViewListener.cs
- DataControlFieldTypeEditor.cs
- XmlToDatasetMap.cs
- CodeSnippetCompileUnit.cs
- PathSegmentCollection.cs
- WebPartEditorOkVerb.cs
- SignerInfo.cs
- ProjectionNode.cs
- ItemAutomationPeer.cs
- DrawingImage.cs
- XmlWriterSettings.cs
- ListViewCommandEventArgs.cs
- SqlDataSourceCommandParser.cs
- LambdaCompiler.Logical.cs
- log.cs
- Animatable.cs
- SingleAnimationBase.cs
- XsltException.cs
- EntitySet.cs
- NullableDoubleSumAggregationOperator.cs
- MetadataAssemblyHelper.cs
- HighlightVisual.cs
- DbDataAdapter.cs
- IgnoreDeviceFilterElement.cs
- Operand.cs
- Pipe.cs
- TextEndOfParagraph.cs
- Wizard.cs
- ZipIOModeEnforcingStream.cs
- DefaultHttpHandler.cs
- ComponentCommands.cs
- ProxyElement.cs
- SByteConverter.cs
- WebRequestModuleElementCollection.cs
- InheritedPropertyChangedEventArgs.cs
- SoapProtocolImporter.cs
- DataSourceSelectArguments.cs
- TransformConverter.cs
- MaxValueConverter.cs
- CurrencyManager.cs
- ThumbButtonInfoCollection.cs
- XmlBinaryWriterSession.cs
- PaperSource.cs
- Parser.cs
- hebrewshape.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- DataControlCommands.cs
- HttpException.cs
- Attributes.cs
- Transaction.cs
- QilNode.cs
- AstNode.cs
- SerializationHelper.cs
- initElementDictionary.cs
- HttpListenerRequest.cs
- EllipseGeometry.cs
- CodeNamespaceCollection.cs
- SmiEventSink.cs
- XmlSchemaSimpleType.cs
- LocalizedNameDescriptionPair.cs
- ColumnHeaderConverter.cs
- WebBrowserContainer.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- ListViewDataItem.cs
- XmlCharacterData.cs
- ReliabilityContractAttribute.cs
- SiteMembershipCondition.cs
- FormClosingEvent.cs
- RegexCharClass.cs
- NullableDoubleMinMaxAggregationOperator.cs
- NavigatingCancelEventArgs.cs
- Style.cs
- CertificateManager.cs
- ScriptControl.cs
- EdmToObjectNamespaceMap.cs
- Walker.cs
- InputGestureCollection.cs
- PropertyChange.cs
- MdiWindowListItemConverter.cs
- XmlCustomFormatter.cs
- Group.cs
- FixedTextView.cs