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
- TabletDeviceInfo.cs
- FunctionGenerator.cs
- SqlDelegatedTransaction.cs
- ValueUtilsSmi.cs
- InputMethodStateTypeInfo.cs
- ReadOnlyCollectionBase.cs
- EndpointAddressAugust2004.cs
- ErrorRuntimeConfig.cs
- storepermission.cs
- DocumentEventArgs.cs
- ServiceProviders.cs
- WebPartConnectionsCancelVerb.cs
- MachineKeySection.cs
- TimeoutTimer.cs
- DataGridViewCellCancelEventArgs.cs
- EditorPartCollection.cs
- PolyLineSegmentFigureLogic.cs
- InkPresenterAutomationPeer.cs
- ImageUrlEditor.cs
- Pointer.cs
- Coordinator.cs
- _BasicClient.cs
- StylusShape.cs
- EntityDataSourceWrapperCollection.cs
- entitydatasourceentitysetnameconverter.cs
- SymbolEqualComparer.cs
- CodeFieldReferenceExpression.cs
- _SpnDictionary.cs
- ZoneLinkButton.cs
- Error.cs
- Literal.cs
- SubpageParagraph.cs
- ScriptResourceHandler.cs
- Transform3D.cs
- GregorianCalendarHelper.cs
- FixedSOMContainer.cs
- WebPartAddingEventArgs.cs
- KeyboardNavigation.cs
- FormattedText.cs
- SystemFonts.cs
- CSharpCodeProvider.cs
- Control.cs
- AspNetHostingPermission.cs
- PeerResolverElement.cs
- DemultiplexingClientMessageFormatter.cs
- StringBuilder.cs
- TypeUtils.cs
- counter.cs
- ECDiffieHellmanCng.cs
- InternalReceiveMessage.cs
- EventLog.cs
- GridViewUpdateEventArgs.cs
- GeometryHitTestResult.cs
- PriorityChain.cs
- ApplicationCommands.cs
- Model3D.cs
- SerializationInfoEnumerator.cs
- OperatorExpressions.cs
- BaseProcessor.cs
- NotifyInputEventArgs.cs
- _ChunkParse.cs
- ListBox.cs
- GridViewCancelEditEventArgs.cs
- SystemWebSectionGroup.cs
- SapiRecoInterop.cs
- RawAppCommandInputReport.cs
- DataRelation.cs
- VirtualDirectoryMapping.cs
- NamedPipeWorkerProcess.cs
- DocComment.cs
- EndEvent.cs
- XmlAttributeCache.cs
- Token.cs
- QilChoice.cs
- AsyncDataRequest.cs
- SchemaNotation.cs
- _HelperAsyncResults.cs
- LeafCellTreeNode.cs
- Int32EqualityComparer.cs
- FontFamily.cs
- PenContext.cs
- SrgsElementFactoryCompiler.cs
- IISMapPath.cs
- Encoder.cs
- PrivilegeNotHeldException.cs
- MultiSelectRootGridEntry.cs
- DateTimeOffsetAdapter.cs
- InfoCardBaseException.cs
- XmlSerializerNamespaces.cs
- ZoneMembershipCondition.cs
- QueryOutputWriter.cs
- InternalReceiveMessage.cs
- CategoryAttribute.cs
- MissingFieldException.cs
- Command.cs
- GeneratedContractType.cs
- HttpFileCollection.cs
- EntityRecordInfo.cs
- DynamicQueryableWrapper.cs
- ObjectAnimationUsingKeyFrames.cs