Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / StringArrayConverter.cs / 1305376 / 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; // ////// 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// 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; // ////// 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EventLogException.cs
- SamlConstants.cs
- TdsRecordBufferSetter.cs
- GridLengthConverter.cs
- ProtectedConfiguration.cs
- Clock.cs
- SystemResources.cs
- BooleanExpr.cs
- Int32EqualityComparer.cs
- SecurityDescriptor.cs
- AssemblyCollection.cs
- SystemException.cs
- RoleService.cs
- SelectionRange.cs
- OdbcDataAdapter.cs
- XappLauncher.cs
- GroupStyle.cs
- RangeValuePattern.cs
- Win32Exception.cs
- MailMessageEventArgs.cs
- DbConnectionClosed.cs
- CriticalHandle.cs
- SortFieldComparer.cs
- QuotaThrottle.cs
- XmlSchemaAny.cs
- SByteConverter.cs
- XmlHierarchyData.cs
- OracleLob.cs
- DockPanel.cs
- HostingEnvironmentSection.cs
- KeyGesture.cs
- COM2PictureConverter.cs
- CqlIdentifiers.cs
- BitmapEffectRenderDataResource.cs
- Executor.cs
- XmlSchemaExporter.cs
- JsonCollectionDataContract.cs
- TriggerBase.cs
- VScrollProperties.cs
- CTreeGenerator.cs
- ChangesetResponse.cs
- ObjectQueryState.cs
- ConvertersCollection.cs
- WinFormsComponentEditor.cs
- StringOutput.cs
- UmAlQuraCalendar.cs
- GcHandle.cs
- FocusTracker.cs
- RegisteredScript.cs
- SqlNodeAnnotations.cs
- Line.cs
- WorkflowElementDialog.cs
- InvalidProgramException.cs
- _Semaphore.cs
- ModelPerspective.cs
- EntityDataSourceWrapperCollection.cs
- MainMenu.cs
- IntPtr.cs
- FreezableDefaultValueFactory.cs
- InkCollectionBehavior.cs
- ValueUtilsSmi.cs
- TextSelectionProcessor.cs
- ConnectionsZoneAutoFormat.cs
- DataRowView.cs
- SiteOfOriginPart.cs
- OleCmdHelper.cs
- SqlDataSourceCache.cs
- SafeFileHandle.cs
- XPathNavigator.cs
- PreProcessInputEventArgs.cs
- DefinitionUpdate.cs
- HtmlLink.cs
- KeyBinding.cs
- FixedHighlight.cs
- ClientSession.cs
- EventDescriptorCollection.cs
- FixedHighlight.cs
- QilExpression.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- BamlBinaryReader.cs
- QilName.cs
- ScriptingRoleServiceSection.cs
- Transform.cs
- PrintDialog.cs
- DataListComponentEditor.cs
- XmlDocumentFragment.cs
- FixedPageStructure.cs
- XmlSchemaType.cs
- MessageContractMemberAttribute.cs
- FrameworkContentElementAutomationPeer.cs
- HttpGetProtocolImporter.cs
- Parsers.cs
- PolyBezierSegment.cs
- HorizontalAlignConverter.cs
- PathSegmentCollection.cs
- PropertyManager.cs
- XmlWrappingReader.cs
- SuppressMessageAttribute.cs
- DelegatingTypeDescriptionProvider.cs
- PropertyGrid.cs