Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ //// 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DoubleConverter.cs
- QueryStringParameter.cs
- Bidi.cs
- SettingsPropertyIsReadOnlyException.cs
- NTAccount.cs
- RedirectionProxy.cs
- CodeMethodReturnStatement.cs
- TextServicesCompartmentContext.cs
- MultipartContentParser.cs
- UIInitializationException.cs
- UIAgentAsyncBeginRequest.cs
- DebuggerService.cs
- ColumnMap.cs
- ReferenceEqualityComparer.cs
- EntityDataReader.cs
- DispatcherExceptionEventArgs.cs
- StreamReader.cs
- ServiceModelTimeSpanValidator.cs
- DataGridViewTextBoxCell.cs
- HtmlEmptyTagControlBuilder.cs
- EastAsianLunisolarCalendar.cs
- DetailsViewUpdateEventArgs.cs
- SafeEventLogReadHandle.cs
- DataFieldEditor.cs
- TransformFinalBlockRequest.cs
- StringConverter.cs
- OdbcConnection.cs
- LicenseProviderAttribute.cs
- SubMenuStyleCollection.cs
- UserControl.cs
- TextEffect.cs
- PublisherMembershipCondition.cs
- ScriptHandlerFactory.cs
- BaseProcessor.cs
- TraceHwndHost.cs
- FlowchartStart.xaml.cs
- WebBrowserUriTypeConverter.cs
- IsolatedStorageFileStream.cs
- RangeBase.cs
- RTLAwareMessageBox.cs
- BitmapSizeOptions.cs
- SchemaImporterExtensionsSection.cs
- MouseActionValueSerializer.cs
- SafeNativeMethods.cs
- RelatedView.cs
- _HeaderInfoTable.cs
- FilteredXmlReader.cs
- ToolTipService.cs
- XmlDownloadManager.cs
- WebPartDisplayModeEventArgs.cs
- MergeExecutor.cs
- WindowsScroll.cs
- PtsContext.cs
- DockingAttribute.cs
- TextSelectionHelper.cs
- ImageField.cs
- CancellationHandler.cs
- WindowsListBox.cs
- SQLInt64.cs
- HtmlForm.cs
- WebResponse.cs
- __Filters.cs
- SourceItem.cs
- UnauthorizedWebPart.cs
- ZipPackagePart.cs
- SignatureDescription.cs
- ResXBuildProvider.cs
- CompilationSection.cs
- TextEffectCollection.cs
- SelectionListComponentEditor.cs
- FileSystemInfo.cs
- RepeatBehavior.cs
- ExpressionNormalizer.cs
- DataKeyCollection.cs
- httpapplicationstate.cs
- RuntimeVariablesExpression.cs
- XsltQilFactory.cs
- HttpEncoderUtility.cs
- StandardCommands.cs
- ObjectDataSourceDesigner.cs
- CodeAttachEventStatement.cs
- PerformanceCounterLib.cs
- AssemblyBuilderData.cs
- SharedPersonalizationStateInfo.cs
- LocalValueEnumerator.cs
- SafeHandles.cs
- ProfilePropertyNameValidator.cs
- ItemContainerGenerator.cs
- ConfigurationProperty.cs
- SerializerDescriptor.cs
- TypefaceMap.cs
- NamespaceTable.cs
- DataGridViewAdvancedBorderStyle.cs
- TransformCollection.cs
- AttachmentService.cs
- filewebresponse.cs
- TextTreeTextElementNode.cs
- MethodExpr.cs
- PreviewPageInfo.cs
- CodeStatement.cs