Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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;
///
/// Provides a type converter to convert string objects to and from various other
/// representations.
///
[HostProtection(SharedState = true)]
public class StringConverter : TypeConverter {
///
/// 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 bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
if (sourceType == typeof(string)) {
return true;
}
return base.CanConvertFrom(context, sourceType);
}
///
/// Converts the specified value object to a string object.
///
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);
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AxisAngleRotation3D.cs
- TaiwanLunisolarCalendar.cs
- HMACSHA384.cs
- AuthStoreRoleProvider.cs
- TextElementEditingBehaviorAttribute.cs
- DemultiplexingClientMessageFormatter.cs
- TreeNodeStyleCollection.cs
- OleDbWrapper.cs
- ControlIdConverter.cs
- ComponentResourceKey.cs
- SortExpressionBuilder.cs
- BasicViewGenerator.cs
- ConnectivityStatus.cs
- LinearGradientBrush.cs
- IteratorFilter.cs
- ServiceModelExtensionElement.cs
- XmlAttributeProperties.cs
- WindowsListViewSubItem.cs
- ActivityDesignerResources.cs
- x509store.cs
- HierarchicalDataBoundControl.cs
- AbsoluteQuery.cs
- IdentityNotMappedException.cs
- ConstraintCollection.cs
- SerializationSectionGroup.cs
- ColumnMapTranslator.cs
- ZipFileInfo.cs
- AssociationSetEnd.cs
- ConcurrencyBehavior.cs
- XmlDictionaryReaderQuotas.cs
- TerminatorSinks.cs
- TdsValueSetter.cs
- QueueNameHelper.cs
- StringOutput.cs
- SourceFilter.cs
- SqlDataSourceSelectingEventArgs.cs
- XmlSchemaSet.cs
- MetadataArtifactLoaderResource.cs
- RowParagraph.cs
- SeekStoryboard.cs
- _SslStream.cs
- BindingMemberInfo.cs
- MailWebEventProvider.cs
- XmlSchemaComplexContent.cs
- TemplateBamlTreeBuilder.cs
- SqlTriggerAttribute.cs
- ProcessStartInfo.cs
- SqlRetyper.cs
- OutputScope.cs
- Internal.cs
- TextTreeRootTextBlock.cs
- XPathNodeIterator.cs
- IsolationInterop.cs
- DesignerValidatorAdapter.cs
- PathGeometry.cs
- Opcode.cs
- MissingManifestResourceException.cs
- FtpWebRequest.cs
- CommandConverter.cs
- CopyAttributesAction.cs
- HttpRawResponse.cs
- ContentPathSegment.cs
- LinqDataSource.cs
- XhtmlCssHandler.cs
- ValueQuery.cs
- ExternalFile.cs
- PeerNameRecordCollection.cs
- PropertyPathConverter.cs
- ProgressBar.cs
- TextEvent.cs
- AdRotatorDesigner.cs
- AuthorizationSection.cs
- ClientData.cs
- ClipboardData.cs
- MimeImporter.cs
- TransactionBehavior.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- NetworkInterface.cs
- Point3DAnimation.cs
- XmlParserContext.cs
- SchemaMapping.cs
- LineGeometry.cs
- Int32Converter.cs
- CultureSpecificCharacterBufferRange.cs
- OutputBuffer.cs
- SiteMapNodeCollection.cs
- HtmlImage.cs
- TransactionManager.cs
- WeakHashtable.cs
- VersionedStream.cs
- IndexerNameAttribute.cs
- DetailsViewCommandEventArgs.cs
- SectionUpdates.cs
- RedirectionProxy.cs
- UpdateException.cs
- pingexception.cs
- Localizer.cs
- UIElementAutomationPeer.cs
- KnownBoxes.cs
- Point3DCollection.cs