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
- SourceLocation.cs
- SecurityTokenException.cs
- XmlBaseReader.cs
- RegexFCD.cs
- IntSecurity.cs
- KeysConverter.cs
- ActivityExecutionContextCollection.cs
- ErrorHandler.cs
- EmptyCollection.cs
- SettingsBindableAttribute.cs
- Operator.cs
- EventHandlers.cs
- OracleConnection.cs
- NativeRecognizer.cs
- ListViewDeletedEventArgs.cs
- Dispatcher.cs
- CancellationTokenRegistration.cs
- CodeMethodInvokeExpression.cs
- FormatterServicesNoSerializableCheck.cs
- SolidColorBrush.cs
- XamlVector3DCollectionSerializer.cs
- UserPersonalizationStateInfo.cs
- DispatcherTimer.cs
- ArgumentsParser.cs
- BamlCollectionHolder.cs
- Query.cs
- AssemblyGen.cs
- _ListenerResponseStream.cs
- WindowsContainer.cs
- DrawingAttributeSerializer.cs
- SqlUserDefinedTypeAttribute.cs
- ReferencedAssembly.cs
- ProxyGenerationError.cs
- LogLogRecordHeader.cs
- WebPartConnectionCollection.cs
- PrefixQName.cs
- Rule.cs
- Int16Storage.cs
- ErrorRuntimeConfig.cs
- TreeIterator.cs
- CreatingCookieEventArgs.cs
- SelectionList.cs
- MarkupCompiler.cs
- IdentityNotMappedException.cs
- DelayedRegex.cs
- PersonalizationStateInfoCollection.cs
- ExpressionBuilder.cs
- Stylus.cs
- AbstractSvcMapFileLoader.cs
- IdnElement.cs
- JournalNavigationScope.cs
- SmtpDateTime.cs
- MimeBasePart.cs
- CheckBoxFlatAdapter.cs
- TextReader.cs
- SchemaTableColumn.cs
- EntityParameterCollection.cs
- WebPartDisplayModeEventArgs.cs
- StringComparer.cs
- NamespaceExpr.cs
- WebBrowserEvent.cs
- TreeNode.cs
- ValuePattern.cs
- DefaultProxySection.cs
- CollectionView.cs
- SafeLibraryHandle.cs
- StreamGeometry.cs
- CachedPathData.cs
- FocusChangedEventArgs.cs
- BulletChrome.cs
- SqlParameterCollection.cs
- IERequestCache.cs
- OdbcFactory.cs
- HttpServerUtilityWrapper.cs
- BitmapSourceSafeMILHandle.cs
- CustomErrorsSection.cs
- TreeNodeCollection.cs
- MultilineStringConverter.cs
- BigInt.cs
- SessionPageStateSection.cs
- FileUtil.cs
- XsdBuilder.cs
- FontWeightConverter.cs
- DataGridViewRowCancelEventArgs.cs
- PageSetupDialog.cs
- CharacterMetrics.cs
- X500Name.cs
- OciEnlistContext.cs
- GlyphInfoList.cs
- CodeExporter.cs
- DecimalSumAggregationOperator.cs
- VisemeEventArgs.cs
- WindowsAltTab.cs
- HttpCookieCollection.cs
- ToolBarPanel.cs
- FloatAverageAggregationOperator.cs
- InteropBitmapSource.cs
- XslTransformFileEditor.cs
- FormViewPagerRow.cs
- Error.cs