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
- StoreItemCollection.cs
- Evidence.cs
- PageParser.cs
- ObjectReferenceStack.cs
- EnumValidator.cs
- IPEndPointCollection.cs
- DefaultTextStore.cs
- _HeaderInfoTable.cs
- Math.cs
- ResXResourceReader.cs
- CodeIndexerExpression.cs
- LinkArea.cs
- SecurityDescriptor.cs
- PriorityQueue.cs
- MonitoringDescriptionAttribute.cs
- SafeLibraryHandle.cs
- TimerExtension.cs
- WinFormsUtils.cs
- HtmlInputReset.cs
- TypeUtils.cs
- IncrementalCompileAnalyzer.cs
- CacheOutputQuery.cs
- CustomErrorsSection.cs
- StateRuntime.cs
- ImportContext.cs
- NonSerializedAttribute.cs
- NumberAction.cs
- __Filters.cs
- NetPeerTcpBindingElement.cs
- WebBrowser.cs
- OracleEncoding.cs
- SystemIPAddressInformation.cs
- SmtpFailedRecipientException.cs
- _NativeSSPI.cs
- ScriptServiceAttribute.cs
- XmlSchemaCompilationSettings.cs
- DataGridViewCell.cs
- WindowsUpDown.cs
- RoleManagerModule.cs
- LocalBuilder.cs
- LinkedResource.cs
- PropertyChangeTracker.cs
- RequestCachingSection.cs
- LineInfo.cs
- InheritanceContextHelper.cs
- DesignerForm.cs
- MemberProjectionIndex.cs
- UnionExpr.cs
- ReadOnlyNameValueCollection.cs
- DiscoveryClientProtocol.cs
- TimeStampChecker.cs
- AutoScrollExpandMessageFilter.cs
- ComAwareEventInfo.cs
- ItemCheckedEvent.cs
- RowSpanVector.cs
- DerivedKeySecurityTokenStub.cs
- ReachDocumentReferenceSerializerAsync.cs
- PenContext.cs
- Converter.cs
- AutomationPropertyInfo.cs
- ContentAlignmentEditor.cs
- ObjectConverter.cs
- PropertyValueUIItem.cs
- Journaling.cs
- ErrorWrapper.cs
- ShadowGlyph.cs
- WpfGeneratedKnownProperties.cs
- OleDbRowUpdatedEvent.cs
- EventLogger.cs
- Overlapped.cs
- TrustLevel.cs
- LoadMessageLogger.cs
- ClientTargetSection.cs
- HintTextConverter.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- Image.cs
- Dynamic.cs
- WebPartMinimizeVerb.cs
- securitycriticaldataformultiplegetandset.cs
- BinaryFormatterWriter.cs
- DesignerRegion.cs
- SecurityTokenRequirement.cs
- ButtonBaseDesigner.cs
- GZipDecoder.cs
- SiteMapHierarchicalDataSourceView.cs
- XmlTextEncoder.cs
- FontUnitConverter.cs
- WindowsFormsSectionHandler.cs
- RetrieveVirtualItemEventArgs.cs
- ModuleConfigurationInfo.cs
- CorrelationToken.cs
- Regex.cs
- Directory.cs
- HtmlFormWrapper.cs
- RepeaterItemEventArgs.cs
- OdbcHandle.cs
- SqlNodeTypeOperators.cs
- ListViewItemSelectionChangedEvent.cs
- Decimal.cs
- BitmapFrameEncode.cs