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
- BrowsableAttribute.cs
- StringArrayConverter.cs
- QueryableDataSourceView.cs
- XmlEventCache.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- assemblycache.cs
- HtmlGenericControl.cs
- PersistNameAttribute.cs
- ContextMenu.cs
- Transform3D.cs
- ExpandCollapseProviderWrapper.cs
- ProxySimple.cs
- ExpressionLexer.cs
- NavigationFailedEventArgs.cs
- RepeaterItem.cs
- AdCreatedEventArgs.cs
- XamlToRtfParser.cs
- WindowsToolbar.cs
- NestPullup.cs
- FixedSOMPage.cs
- DateTimeFormatInfoScanner.cs
- HelpEvent.cs
- CacheMode.cs
- DiscoveryClientRequestChannel.cs
- CssClassPropertyAttribute.cs
- TouchEventArgs.cs
- MsmqChannelFactoryBase.cs
- ConsumerConnectionPoint.cs
- FormatterConverter.cs
- Set.cs
- OLEDB_Util.cs
- PageThemeCodeDomTreeGenerator.cs
- HasCopySemanticsAttribute.cs
- CheckBoxField.cs
- DBCSCodePageEncoding.cs
- Table.cs
- FreezableOperations.cs
- StatusBarItemAutomationPeer.cs
- SiteMapHierarchicalDataSourceView.cs
- PolyQuadraticBezierSegment.cs
- SynchronizingStream.cs
- ShutDownListener.cs
- AlignmentYValidation.cs
- TextTabProperties.cs
- MouseGesture.cs
- UnauthorizedAccessException.cs
- SqlComparer.cs
- UriParserTemplates.cs
- HttpModuleCollection.cs
- SapiRecognizer.cs
- TextEndOfParagraph.cs
- PipelineModuleStepContainer.cs
- XsdDuration.cs
- PerformanceCounterPermissionAttribute.cs
- SqlGatherProducedAliases.cs
- GeneralTransformCollection.cs
- CompiledAction.cs
- InvokePattern.cs
- ButtonFieldBase.cs
- XslException.cs
- LicenseProviderAttribute.cs
- DataGridItemEventArgs.cs
- WebFormsRootDesigner.cs
- DeclarativeCatalogPart.cs
- ExtenderProvidedPropertyAttribute.cs
- ResourcePool.cs
- TreeNodeStyle.cs
- SystemPens.cs
- NeedSkipTokenVisitor.cs
- PointLightBase.cs
- GridViewRow.cs
- HierarchicalDataBoundControl.cs
- Assembly.cs
- SpecialFolderEnumConverter.cs
- Sql8ExpressionRewriter.cs
- ButtonStandardAdapter.cs
- IntSecurity.cs
- PhysicalOps.cs
- HttpCookie.cs
- VirtualPath.cs
- BasicAsyncResult.cs
- UnsafeNativeMethods.cs
- Pick.cs
- BinaryCommonClasses.cs
- NameValueFileSectionHandler.cs
- EtwTrace.cs
- SerializationHelper.cs
- _ContextAwareResult.cs
- WindowsGrip.cs
- ChangeBlockUndoRecord.cs
- EntitySetBase.cs
- Select.cs
- JavaScriptObjectDeserializer.cs
- DataGridTextBoxColumn.cs
- cookieexception.cs
- HebrewNumber.cs
- PropertyEntry.cs
- ControlBuilder.cs
- XmlSchemas.cs
- LabelEditEvent.cs