Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / UI / WebControls / StringArrayConverter.cs / 2 / StringArrayConverter.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System.ComponentModel.Design;
using System;
using System.ComponentModel;
using System.Collections;
using System.Globalization;
using System.Security.Permissions;
//
///
/// Converts a string separated by commas to and from
/// an array of strings.
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class StringArrayConverter : TypeConverter {
///
/// Determines if the specified data type can be converted to an array of strings.
///
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
if (sourceType == typeof(string)) {
return true;
}
return false;
}
///
/// Parses a string separated by
/// commas into an array of strings.
///
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
if (value is string) {
if (((string)value).Length == 0) {
return new string[0];
}
// hard code comma, since it is persisted to HTML
//
string[] names = ((string)value).Split(new char[] {','});
for (int i=0; i
/// Creates a string separated
/// by commas from an array of strings.
///
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
if (destinationType == typeof(string)) {
if (value == null) {
return String.Empty;
}
// hard code comma, since it is persisted to HTML
//
return string.Join(",", ((string[])value));
}
throw GetConvertToException(value, destinationType);
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Configuration.cs
- HttpSessionStateWrapper.cs
- CodeTypeParameterCollection.cs
- SoapObjectInfo.cs
- CodeGeneratorOptions.cs
- entityreference_tresulttype.cs
- UIElement3D.cs
- ArrayTypeMismatchException.cs
- querybuilder.cs
- NativeMethods.cs
- DataGridViewAccessibleObject.cs
- Compiler.cs
- ResourceKey.cs
- tooltip.cs
- TreeNode.cs
- ResourceWriter.cs
- SiteMapSection.cs
- InvalidPropValue.cs
- MailAddressCollection.cs
- CheckBoxPopupAdapter.cs
- DocumentXmlWriter.cs
- MenuTracker.cs
- ContractBase.cs
- XPathDocumentBuilder.cs
- QuaternionKeyFrameCollection.cs
- DataObjectAttribute.cs
- DataIdProcessor.cs
- SafeRegistryKey.cs
- TemplateBamlTreeBuilder.cs
- PageBuildProvider.cs
- ObjectRef.cs
- AuthStoreRoleProvider.cs
- LiteralControl.cs
- InstanceHandle.cs
- TryExpression.cs
- _AutoWebProxyScriptWrapper.cs
- _DomainName.cs
- DispatcherFrame.cs
- DataGridViewComboBoxColumn.cs
- NodeLabelEditEvent.cs
- MemoryPressure.cs
- Scripts.cs
- DurableEnlistmentState.cs
- MethodMessage.cs
- AlignmentXValidation.cs
- DataGridViewCellCancelEventArgs.cs
- TextFormatterHost.cs
- DbSourceCommand.cs
- ContractNamespaceAttribute.cs
- WorkflowTraceTransfer.cs
- BindUriHelper.cs
- SrgsText.cs
- EntityDataSourceReferenceGroup.cs
- PolyLineSegment.cs
- DbExpressionRules.cs
- UniqueCodeIdentifierScope.cs
- ConfigXmlWhitespace.cs
- DtrList.cs
- HtmlSelectionListAdapter.cs
- ZoneButton.cs
- CreateUserErrorEventArgs.cs
- X509Utils.cs
- ZipFileInfo.cs
- ExpressionTable.cs
- Effect.cs
- ApplicationInfo.cs
- SystemNetHelpers.cs
- TypeSource.cs
- PhysicalAddress.cs
- TableItemStyle.cs
- SqlCommandSet.cs
- TypeUnloadedException.cs
- WebBrowsableAttribute.cs
- Brush.cs
- FontNamesConverter.cs
- ResponseBodyWriter.cs
- IntPtr.cs
- GenericWebPart.cs
- HttpGetProtocolReflector.cs
- BrushConverter.cs
- TimeSpanConverter.cs
- Font.cs
- HandleValueEditor.cs
- ParameterExpression.cs
- SqlDataSourceFilteringEventArgs.cs
- LocalIdKeyIdentifierClause.cs
- CaseInsensitiveComparer.cs
- AspNetSynchronizationContext.cs
- TriState.cs
- MemoryStream.cs
- ClassGenerator.cs
- wgx_sdk_version.cs
- FormatConvertedBitmap.cs
- DrawListViewItemEventArgs.cs
- EncryptedReference.cs
- GenericXmlSecurityToken.cs
- _Win32.cs
- AppSettings.cs
- AssemblyCache.cs
- DBConcurrencyException.cs