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
- _UriTypeConverter.cs
- QueryComponents.cs
- VisualTarget.cs
- StylusEditingBehavior.cs
- ComponentDispatcher.cs
- WindowsMenu.cs
- BooleanToVisibilityConverter.cs
- AppSettingsExpressionBuilder.cs
- IList.cs
- LayoutEditorPart.cs
- _TransmitFileOverlappedAsyncResult.cs
- TextSchema.cs
- ToolTip.cs
- WebPartZoneCollection.cs
- RegexWorker.cs
- UncommonField.cs
- CmsUtils.cs
- XmlSchemaObjectCollection.cs
- ConcurrentDictionary.cs
- SingleKeyFrameCollection.cs
- ValidationRuleCollection.cs
- Overlapped.cs
- NativeMethods.cs
- ComponentResourceKey.cs
- ObjectDataSourceMethodEventArgs.cs
- StreamingContext.cs
- FileReservationCollection.cs
- ParentUndoUnit.cs
- TextStore.cs
- ListViewItemSelectionChangedEvent.cs
- PolyBezierSegment.cs
- AssemblyAttributes.cs
- HiddenFieldDesigner.cs
- LinqDataSourceDeleteEventArgs.cs
- Mutex.cs
- TextElementCollectionHelper.cs
- ProtocolsSection.cs
- HScrollProperties.cs
- TextBoxAutoCompleteSourceConverter.cs
- ResourceExpression.cs
- MimeFormatter.cs
- NameTable.cs
- NGCPageContentSerializerAsync.cs
- ErrorTolerantObjectWriter.cs
- DynamicQueryStringParameter.cs
- CodeExporter.cs
- CreatingCookieEventArgs.cs
- Thickness.cs
- DynamicAttribute.cs
- SapiRecoContext.cs
- ParameterBinding.cs
- SchemaAttDef.cs
- HwndSourceKeyboardInputSite.cs
- FaultContext.cs
- CompiledIdentityConstraint.cs
- ExitEventArgs.cs
- DynamicRouteExpression.cs
- DataGridViewToolTip.cs
- ItemContainerGenerator.cs
- RefreshPropertiesAttribute.cs
- IHttpResponseInternal.cs
- Transform.cs
- XslVisitor.cs
- ObjectListCommand.cs
- CompoundFileReference.cs
- DbDeleteCommandTree.cs
- _ConnectionGroup.cs
- DBSchemaTable.cs
- MatrixStack.cs
- FormViewCommandEventArgs.cs
- OrderToken.cs
- HtmlTableRowCollection.cs
- WebPartCancelEventArgs.cs
- PathParser.cs
- ActivityCodeDomReferenceService.cs
- ModelPerspective.cs
- EventRoute.cs
- ADMembershipUser.cs
- TemplateControl.cs
- DataGridViewColumn.cs
- RowSpanVector.cs
- ComboBox.cs
- StrokeNodeOperations2.cs
- EntityUtil.cs
- ConfigurationSection.cs
- MatrixValueSerializer.cs
- OrderByBuilder.cs
- ComponentEvent.cs
- DataSet.cs
- InstalledVoice.cs
- ColorKeyFrameCollection.cs
- TextOnlyOutput.cs
- PrimitiveType.cs
- Blend.cs
- SqlDataSourceSelectingEventArgs.cs
- URIFormatException.cs
- Encoder.cs
- SymLanguageVendor.cs
- UITypeEditor.cs
- WebPartsPersonalizationAuthorization.cs