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
- Utils.cs
- RtfToXamlReader.cs
- ConnectionDemuxer.cs
- MarkupCompilePass1.cs
- StreamUpgradeBindingElement.cs
- CompositeTypefaceMetrics.cs
- StaticSiteMapProvider.cs
- Context.cs
- XmlTextReaderImpl.cs
- ReflectionPermission.cs
- MenuEventArgs.cs
- BrowserCapabilitiesCompiler.cs
- DashStyles.cs
- UnhandledExceptionEventArgs.cs
- ThreadInterruptedException.cs
- ParamArrayAttribute.cs
- ProfileGroupSettingsCollection.cs
- Semaphore.cs
- DynamicUpdateCommand.cs
- PartialCachingAttribute.cs
- EventTrigger.cs
- Error.cs
- SmiTypedGetterSetter.cs
- TouchesCapturedWithinProperty.cs
- DocumentPageHost.cs
- AppDomainProtocolHandler.cs
- SymmetricSecurityProtocolFactory.cs
- ObservableDictionary.cs
- DataError.cs
- HitTestParameters3D.cs
- SmtpCommands.cs
- DetailsViewModeEventArgs.cs
- Overlapped.cs
- QuaternionKeyFrameCollection.cs
- FormViewRow.cs
- NamespaceDecl.cs
- DummyDataSource.cs
- DirectoryObjectSecurity.cs
- MsmqIntegrationBindingElement.cs
- EpmContentDeSerializer.cs
- OutputCacheProfile.cs
- EmptyElement.cs
- UnauthorizedAccessException.cs
- Pen.cs
- StringCollection.cs
- QilPatternFactory.cs
- ProcessStartInfo.cs
- XPathDocumentBuilder.cs
- NamespaceCollection.cs
- DifferencingCollection.cs
- RadioButton.cs
- ConsoleEntryPoint.cs
- SoapFault.cs
- BatchParser.cs
- FormViewUpdateEventArgs.cs
- InkCanvasSelectionAdorner.cs
- MethodBuilderInstantiation.cs
- Wildcard.cs
- GenerateHelper.cs
- VerificationAttribute.cs
- SchemaDeclBase.cs
- RepeatEnumerable.cs
- BuilderInfo.cs
- ChtmlTextWriter.cs
- XmlSchemaSimpleTypeList.cs
- HtmlContainerControl.cs
- ColumnWidthChangedEvent.cs
- SyndicationPerson.cs
- RegisteredExpandoAttribute.cs
- XmlBoundElement.cs
- SamlDelegatingWriter.cs
- InvokeBase.cs
- MetadataPropertyAttribute.cs
- OdbcConnectionFactory.cs
- RTLAwareMessageBox.cs
- ChangePassword.cs
- CommandField.cs
- OleDbException.cs
- COM2Properties.cs
- CommonXSendMessage.cs
- DeploymentExceptionMapper.cs
- RegexInterpreter.cs
- DataListItemCollection.cs
- DesignerCalendarAdapter.cs
- RegisterInfo.cs
- TraceHwndHost.cs
- IResourceProvider.cs
- GcSettings.cs
- DeadCharTextComposition.cs
- NamespaceList.cs
- PropertyMapper.cs
- FormViewCommandEventArgs.cs
- SqlClientWrapperSmiStreamChars.cs
- ConsumerConnectionPointCollection.cs
- TextFormatterContext.cs
- safemediahandle.cs
- StringValueSerializer.cs
- DefaultWorkflowSchedulerService.cs
- PriorityQueue.cs
- SqlTriggerAttribute.cs