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
- XmlSchemaComplexType.cs
- EventManager.cs
- CheckPair.cs
- UDPClient.cs
- CompilationUtil.cs
- WhitespaceRule.cs
- CatalogPartCollection.cs
- BmpBitmapDecoder.cs
- StorageInfo.cs
- OracleConnectionStringBuilder.cs
- EnumerationRangeValidationUtil.cs
- TypedCompletedAsyncResult.cs
- Soap.cs
- RSAPKCS1KeyExchangeFormatter.cs
- XhtmlMobileTextWriter.cs
- SourceSwitch.cs
- ProtectedConfiguration.cs
- SendKeys.cs
- UseLicense.cs
- SqlOuterApplyReducer.cs
- DBSqlParser.cs
- Schema.cs
- CopyNamespacesAction.cs
- DerivedKeySecurityTokenStub.cs
- ParameterToken.cs
- SafeIUnknown.cs
- AsyncResult.cs
- StartUpEventArgs.cs
- HttpPostedFile.cs
- DataGridTextBox.cs
- OperandQuery.cs
- ProgressiveCrcCalculatingStream.cs
- ExternalDataExchangeService.cs
- PropertyDescriptorComparer.cs
- keycontainerpermission.cs
- Base64Stream.cs
- ZipIOLocalFileBlock.cs
- DBParameter.cs
- _SslStream.cs
- HttpException.cs
- RoleServiceManager.cs
- Html32TextWriter.cs
- ResourceDefaultValueAttribute.cs
- Transform.cs
- SettingsSection.cs
- SharedPerformanceCounter.cs
- ExpandableObjectConverter.cs
- ServiceChannelFactory.cs
- Rules.cs
- XmlBinaryWriter.cs
- TraceRecords.cs
- SQLInt64Storage.cs
- TabControlEvent.cs
- TypeContext.cs
- EntityTypeBase.cs
- XD.cs
- DefaultTraceListener.cs
- OperationAbortedException.cs
- CookielessHelper.cs
- DefaultSection.cs
- EntityViewGenerationConstants.cs
- BindValidator.cs
- CachedBitmap.cs
- PerspectiveCamera.cs
- XmlTextEncoder.cs
- WebPartCancelEventArgs.cs
- XslVisitor.cs
- Tool.cs
- DataGridViewAddColumnDialog.cs
- ChtmlTextWriter.cs
- BuildProvider.cs
- AbsoluteQuery.cs
- XmlMtomWriter.cs
- FormatSettings.cs
- ProbeMatchesMessage11.cs
- RadioButtonBaseAdapter.cs
- SqlCrossApplyToCrossJoin.cs
- CodePropertyReferenceExpression.cs
- ListViewAutomationPeer.cs
- VersionedStream.cs
- XhtmlConformanceSection.cs
- WorkflowOperationAsyncResult.cs
- MemberBinding.cs
- SmtpReplyReader.cs
- HostUtils.cs
- EntitySetBaseCollection.cs
- SBCSCodePageEncoding.cs
- TemplateKeyConverter.cs
- StateRuntime.cs
- ServiceTimeoutsBehavior.cs
- PackWebResponse.cs
- MissingMethodException.cs
- MessageDecoder.cs
- processwaithandle.cs
- SystemUnicastIPAddressInformation.cs
- TileBrush.cs
- ContextTokenTypeConverter.cs
- ColumnHeader.cs
- FieldNameLookup.cs
- NetworkAddressChange.cs