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; // ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class StringArrayConverter : TypeConverter { ///Converts a string separated by commas to and from /// an array of strings. ////// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return false; } ///Determines if the specified data type can be converted to 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; iParses a string separated by /// commas into an array of strings. ////// 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
- DataPagerFieldCollection.cs
- Vector3DConverter.cs
- RequestCachingSection.cs
- ManagedFilter.cs
- UrlMappingCollection.cs
- CmsUtils.cs
- Listen.cs
- smtppermission.cs
- TextSearch.cs
- SolidColorBrush.cs
- DoWorkEventArgs.cs
- EntityCommandDefinition.cs
- Convert.cs
- Point.cs
- SqlDataSourceDesigner.cs
- DocumentXPathNavigator.cs
- DynamicValueConverter.cs
- CollectionViewGroup.cs
- StringTraceRecord.cs
- ViewKeyConstraint.cs
- Soap.cs
- WMICapabilities.cs
- ObjectPersistData.cs
- FontStyleConverter.cs
- HopperCache.cs
- EdmItemError.cs
- DataBindingHandlerAttribute.cs
- DecimalStorage.cs
- IUnknownConstantAttribute.cs
- DataMember.cs
- BufferedReadStream.cs
- FormClosingEvent.cs
- MemberMaps.cs
- ProjectionRewriter.cs
- XmlNamespaceDeclarationsAttribute.cs
- LocatorBase.cs
- DataTableNewRowEvent.cs
- SimpleWorkerRequest.cs
- ColorConvertedBitmapExtension.cs
- SafeRightsManagementEnvironmentHandle.cs
- RSAOAEPKeyExchangeDeformatter.cs
- TCPClient.cs
- MappingException.cs
- TextParaClient.cs
- Request.cs
- Matrix3DStack.cs
- BitmapEffectDrawingContextState.cs
- WpfKnownMemberInvoker.cs
- FixedPageAutomationPeer.cs
- HebrewNumber.cs
- FileDialogCustomPlacesCollection.cs
- MissingSatelliteAssemblyException.cs
- ExpressionBindingCollection.cs
- ChangePassword.cs
- XmlCountingReader.cs
- RegexStringValidatorAttribute.cs
- MenuScrollingVisibilityConverter.cs
- IsolatedStorageFileStream.cs
- WebPartsSection.cs
- precedingsibling.cs
- RegisteredHiddenField.cs
- AssociationSetMetadata.cs
- Semaphore.cs
- ReturnValue.cs
- StringBuilder.cs
- BitmapCodecInfo.cs
- OLEDB_Enum.cs
- TypeDescriptionProviderAttribute.cs
- Grant.cs
- TagElement.cs
- DESCryptoServiceProvider.cs
- StyleXamlTreeBuilder.cs
- List.cs
- DaylightTime.cs
- SqlCacheDependencySection.cs
- KeyValueConfigurationCollection.cs
- Timer.cs
- SimpleRecyclingCache.cs
- ZipIOExtraFieldElement.cs
- StructureChangedEventArgs.cs
- DataColumnPropertyDescriptor.cs
- TextDpi.cs
- SqlUtil.cs
- SourceElementsCollection.cs
- TransformerInfoCollection.cs
- WorkflowOwnershipException.cs
- XmlAnyElementAttribute.cs
- ObjectHandle.cs
- RegexWorker.cs
- HtmlMeta.cs
- Label.cs
- ZipPackage.cs
- SelectionEditor.cs
- MarkerProperties.cs
- FormViewRow.cs
- ListViewGroupCollectionEditor.cs
- PagerSettings.cs
- HashStream.cs
- DependentTransaction.cs
- DoubleAnimationClockResource.cs