Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / ComponentModel / StringConverter.cs / 1 / StringConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.ComponentModel { using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.Runtime.Remoting; using System.Runtime.Serialization.Formatters; using System.Security.Permissions; ////// [HostProtection(SharedState = true)] public class StringConverter : TypeConverter { ///Provides a type converter to convert string objects to and from various other /// representations. ////// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } ///Gets a value indicating whether this converter can convert an object in the /// given source type to a string using the specified context. ////// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { return (string)value; } if (value == null) { return ""; } return base.ConvertFrom(context, culture, value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //Converts the specified value object to a string object. ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.ComponentModel { using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.Runtime.Remoting; using System.Runtime.Serialization.Formatters; using System.Security.Permissions; ////// [HostProtection(SharedState = true)] public class StringConverter : TypeConverter { ///Provides a type converter to convert string objects to and from various other /// representations. ////// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } ///Gets a value indicating whether this converter can convert an object in the /// given source type to a string using the specified context. ////// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { return (string)value; } if (value == null) { return ""; } return base.ConvertFrom(context, culture, value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.Converts the specified value object to a string object. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FrameworkElement.cs
- MultiBindingExpression.cs
- TypeLibraryHelper.cs
- Identity.cs
- SmiEventStream.cs
- ScriptResourceHandler.cs
- HandledMouseEvent.cs
- XamlReader.cs
- ThrowHelper.cs
- TcpAppDomainProtocolHandler.cs
- NameValueConfigurationCollection.cs
- XmlCollation.cs
- JsonObjectDataContract.cs
- WsdlImporterElementCollection.cs
- BitmapEffectState.cs
- _FixedSizeReader.cs
- DataGridViewLinkColumn.cs
- BasicHttpBinding.cs
- MouseEventArgs.cs
- DataGridColumn.cs
- XmlSerializerNamespaces.cs
- EntityType.cs
- XmlDomTextWriter.cs
- TableAutomationPeer.cs
- TargetControlTypeAttribute.cs
- EdmTypeAttribute.cs
- DeobfuscatingStream.cs
- ChannelManager.cs
- CompiledXpathExpr.cs
- _Win32.cs
- CommandEventArgs.cs
- FrameworkRichTextComposition.cs
- UTF7Encoding.cs
- TemplateControlBuildProvider.cs
- WebPartChrome.cs
- ContentDisposition.cs
- SubclassTypeValidator.cs
- MimeWriter.cs
- TypeExtensions.cs
- NativeMethods.cs
- CapabilitiesPattern.cs
- FormatSettings.cs
- EventRoute.cs
- GeneratedCodeAttribute.cs
- GuidelineSet.cs
- Scalars.cs
- SoapObjectInfo.cs
- NonParentingControl.cs
- ISAPIApplicationHost.cs
- SqlWebEventProvider.cs
- TextContainerChangeEventArgs.cs
- EventLogPermission.cs
- WebResourceUtil.cs
- AlternateViewCollection.cs
- SqlGatherConsumedAliases.cs
- TabItemAutomationPeer.cs
- LinearGradientBrush.cs
- ConstructorArgumentAttribute.cs
- Classification.cs
- TextContainerChangedEventArgs.cs
- GridViewCellAutomationPeer.cs
- LayoutInformation.cs
- BridgeDataRecord.cs
- OrCondition.cs
- ApplicationProxyInternal.cs
- ExtendedPropertyDescriptor.cs
- Visitors.cs
- M3DUtil.cs
- ProfileSection.cs
- AppDomainEvidenceFactory.cs
- WebPartMenuStyle.cs
- HandoffBehavior.cs
- WebPartDisplayModeCancelEventArgs.cs
- DataGridViewDataErrorEventArgs.cs
- SqlDataReader.cs
- SoapInteropTypes.cs
- CuspData.cs
- FormatConvertedBitmap.cs
- PlatformCulture.cs
- QueryResultOp.cs
- ProviderCollection.cs
- MouseButtonEventArgs.cs
- UncommonField.cs
- DataKeyArray.cs
- Int32EqualityComparer.cs
- ClientScriptManager.cs
- ValidationErrorCollection.cs
- HttpRequest.cs
- ConfigurationSectionCollection.cs
- TypeForwardedToAttribute.cs
- ByteRangeDownloader.cs
- DataGridViewColumnStateChangedEventArgs.cs
- FormatSettings.cs
- OleDbDataAdapter.cs
- AsynchronousChannel.cs
- DataError.cs
- HttpRawResponse.cs
- BaseCodeDomTreeGenerator.cs
- ImmutableObjectAttribute.cs
- ReflectPropertyDescriptor.cs