Code:
/ DotNET / DotNET / 8.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
- RadialGradientBrush.cs
- XmlAttributes.cs
- LifetimeServices.cs
- DataShape.cs
- SoapHeaderAttribute.cs
- OrthographicCamera.cs
- CheckBox.cs
- ServiceHostingEnvironment.cs
- DataGridTableCollection.cs
- WorkflowQueuingService.cs
- UshortList2.cs
- ProxyWebPartManager.cs
- FixedSOMPageElement.cs
- BackStopAuthenticationModule.cs
- DataListItemCollection.cs
- WpfKnownMember.cs
- AtomParser.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- BufferedReceiveManager.cs
- BoundingRectTracker.cs
- RecognizedWordUnit.cs
- GraphicsContext.cs
- HierarchicalDataSourceConverter.cs
- ContentWrapperAttribute.cs
- SiteIdentityPermission.cs
- ReadOnlyAttribute.cs
- TreeNodeConverter.cs
- _PooledStream.cs
- SecurityContext.cs
- NonBatchDirectoryCompiler.cs
- PublisherMembershipCondition.cs
- EntityDataSourceWrapper.cs
- PeerChannelListener.cs
- ServiceAuthorizationElement.cs
- ProxyGenerationError.cs
- SharedDp.cs
- CharKeyFrameCollection.cs
- LinqDataSourceValidationException.cs
- StrongNamePublicKeyBlob.cs
- DataGridViewCellStateChangedEventArgs.cs
- MethodInfo.cs
- StrokeSerializer.cs
- SmtpNtlmAuthenticationModule.cs
- EpmCustomContentWriterNodeData.cs
- WinFormsComponentEditor.cs
- PtsCache.cs
- PeerApplication.cs
- securitycriticaldata.cs
- UnsignedPublishLicense.cs
- recordstatescratchpad.cs
- ReadOnlyAttribute.cs
- mda.cs
- Color.cs
- UnlockCardRequest.cs
- EventPropertyMap.cs
- Rule.cs
- RefreshInfo.cs
- AutomationPropertyInfo.cs
- BooleanSwitch.cs
- ValueProviderWrapper.cs
- DefaultTextStoreTextComposition.cs
- FixedTextSelectionProcessor.cs
- PackageRelationshipCollection.cs
- ContextDataSourceContextData.cs
- WindowsRichEditRange.cs
- EnumerableCollectionView.cs
- XPathAncestorIterator.cs
- ParallelTimeline.cs
- PathTooLongException.cs
- FixedHighlight.cs
- ResXResourceSet.cs
- XmlHierarchicalEnumerable.cs
- BaseTemplateCodeDomTreeGenerator.cs
- MessageDesigner.cs
- CSharpCodeProvider.cs
- ErrorItem.cs
- VariableQuery.cs
- CommandLibraryHelper.cs
- ProtocolReflector.cs
- DataPagerField.cs
- UInt32Converter.cs
- AutomationElementCollection.cs
- CodeMemberProperty.cs
- DataGridClipboardCellContent.cs
- DataGridViewCellValidatingEventArgs.cs
- CellTreeNodeVisitors.cs
- NamedPipeProcessProtocolHandler.cs
- InvalidStoreProtectionKeyException.cs
- StatusBar.cs
- XmlSchemaAny.cs
- InputDevice.cs
- ToolStripSeparator.cs
- EncryptedXml.cs
- LineUtil.cs
- MergeEnumerator.cs
- ResourceReader.cs
- Command.cs
- TaskHelper.cs
- EventHandlersStore.cs
- DesignerRegionCollection.cs