Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / FontNamesConverter.cs / 1305376 / FontNamesConverter.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; ////// Converts a string with font names separated by commas to and from /// an array of strings containing individual names. /// public class FontNamesConverter : TypeConverter { ////// Determines if the specified data type can be converted to an array of strings /// containing individual font names. /// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return false; } ////// Parses a string that represents a list of font names separated by /// commas into an array of strings containing individual font names. /// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { if (((string)value).Length == 0) { return new string[0]; } string[] names = ((string)value).Split(new char[] { culture.TextInfo.ListSeparator[0] }); for (int i = 0; i < names.Length; i++) { names[i] = names[i].Trim(); } return names; } throw GetConvertFromException(value); } ////// Creates a string that represents a list of font names separated /// by commas from an array of strings containing individual font names. /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { if (value == null) { return String.Empty; } return string.Join(culture.TextInfo.ListSeparator, ((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; ////// Converts a string with font names separated by commas to and from /// an array of strings containing individual names. /// public class FontNamesConverter : TypeConverter { ////// Determines if the specified data type can be converted to an array of strings /// containing individual font names. /// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return false; } ////// Parses a string that represents a list of font names separated by /// commas into an array of strings containing individual font names. /// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { if (((string)value).Length == 0) { return new string[0]; } string[] names = ((string)value).Split(new char[] { culture.TextInfo.ListSeparator[0] }); for (int i = 0; i < names.Length; i++) { names[i] = names[i].Trim(); } return names; } throw GetConvertFromException(value); } ////// Creates a string that represents a list of font names separated /// by commas from an array of strings containing individual font names. /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { if (value == null) { return String.Empty; } return string.Join(culture.TextInfo.ListSeparator, ((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
- ObjectItemAssemblyLoader.cs
- KeyGestureConverter.cs
- DataGridTextBoxColumn.cs
- XmlBindingWorker.cs
- HttpVersion.cs
- Token.cs
- FolderNameEditor.cs
- ServiceModelEnumValidatorAttribute.cs
- GeneralTransform3D.cs
- PermissionListSet.cs
- ConstructorNeedsTagAttribute.cs
- SmiEventSink_DeferedProcessing.cs
- DBNull.cs
- glyphs.cs
- FrameDimension.cs
- TypeElementCollection.cs
- WinInetCache.cs
- CodeGenHelper.cs
- MdiWindowListStrip.cs
- GridViewActionList.cs
- SeverityFilter.cs
- InvalidComObjectException.cs
- OdbcDataReader.cs
- ImageAttributes.cs
- ImageAttributes.cs
- DiscoveryDocumentReference.cs
- HyperLinkStyle.cs
- XmlIncludeAttribute.cs
- XmlIncludeAttribute.cs
- OdbcDataReader.cs
- _CommandStream.cs
- BindingSource.cs
- AudioFormatConverter.cs
- XmlHierarchicalEnumerable.cs
- ThrowOnMultipleAssignment.cs
- XPathPatternBuilder.cs
- CompModSwitches.cs
- cookie.cs
- ConnectionPoint.cs
- RecordManager.cs
- MultiSelectRootGridEntry.cs
- Crc32.cs
- WmlLiteralTextAdapter.cs
- Section.cs
- IdnMapping.cs
- QuaternionAnimation.cs
- ConstantCheck.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- WmlLinkAdapter.cs
- QilExpression.cs
- StorageSetMapping.cs
- ListChangedEventArgs.cs
- SqlDataSourceEnumerator.cs
- SelectionEditingBehavior.cs
- AppSettingsReader.cs
- XNodeValidator.cs
- Message.cs
- ForwardPositionQuery.cs
- MailDefinitionBodyFileNameEditor.cs
- Button.cs
- DeclaredTypeValidatorAttribute.cs
- XmlAnyAttributeAttribute.cs
- X509SecurityTokenProvider.cs
- DbParameterCollectionHelper.cs
- CodeDesigner.cs
- TypeValidationEventArgs.cs
- LoginUtil.cs
- DataGridBoolColumn.cs
- PopupRootAutomationPeer.cs
- DataPointer.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- ScaleTransform3D.cs
- OleDbInfoMessageEvent.cs
- Animatable.cs
- ListParagraph.cs
- DataGridRelationshipRow.cs
- ComponentCommands.cs
- HtmlTextViewAdapter.cs
- QilDataSource.cs
- SystemIPGlobalProperties.cs
- ClaimComparer.cs
- EventMappingSettingsCollection.cs
- TerminatorSinks.cs
- SymLanguageVendor.cs
- ConfigurationValue.cs
- ApplicationServicesHostFactory.cs
- Imaging.cs
- CommunicationObjectFaultedException.cs
- OdbcCommandBuilder.cs
- PasswordBox.cs
- PropertyIdentifier.cs
- RightsManagementEncryptionTransform.cs
- PermissionToken.cs
- ISAPIRuntime.cs
- CodeArrayIndexerExpression.cs
- cookiecollection.cs
- BindingManagerDataErrorEventArgs.cs
- ApplicationManager.cs
- DeclarativeCatalogPart.cs
- ImageIndexConverter.cs