Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / UI / WebControls / VerticalAlignConverter.cs / 1 / VerticalAlignConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- // namespace System.Web.UI.WebControls { using System; using System.Collections; using System.ComponentModel; using System.Globalization; internal class VerticalAlignConverter : EnumConverter { static string[] stringValues = new String[(int) VerticalAlign.Bottom + 1]; static VerticalAlignConverter () { stringValues[(int) VerticalAlign.NotSet] = "NotSet"; stringValues[(int) VerticalAlign.Top] = "Top"; stringValues[(int) VerticalAlign.Middle] = "Middle"; stringValues[(int) VerticalAlign.Bottom] = "Bottom"; } // this constructor needs to be public despite the fact that it's in an internal // class so it can be created by Activator.CreateInstance. public VerticalAlignConverter () : base(typeof(VerticalAlign)) {} public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } else { return base.CanConvertFrom(context, sourceType); } } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value == null) return null; if (value is string) { string textValue = ((string)value).Trim(); if (textValue.Length == 0) return VerticalAlign.NotSet; switch (textValue) { case "NotSet": return VerticalAlign.NotSet; case "Top": return VerticalAlign.Top; case "Middle": return VerticalAlign.Middle; case "Bottom": return VerticalAlign.Bottom; } } return base.ConvertFrom(context, culture, value); } public override bool CanConvertTo(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertTo(context, sourceType); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string) && ((int) value <= (int)VerticalAlign.Bottom)) { return stringValues[(int) value]; } return base.ConvertTo(context, culture, value, destinationType); } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TypeCollectionPropertyEditor.cs
- SQLSingle.cs
- SqlWriter.cs
- SqlDependencyListener.cs
- TraceLog.cs
- SapiRecognizer.cs
- WebPartTransformer.cs
- storepermission.cs
- CommittableTransaction.cs
- PeerSecurityHelpers.cs
- Constant.cs
- XmlQualifiedName.cs
- ILGenerator.cs
- IdentityReference.cs
- Variable.cs
- HttpProfileBase.cs
- CompositeActivityTypeDescriptorProvider.cs
- NamedElement.cs
- AutomationElementCollection.cs
- RowToParametersTransformer.cs
- InvalidOleVariantTypeException.cs
- OrderToken.cs
- IncomingWebResponseContext.cs
- FamilyTypefaceCollection.cs
- GridViewCommandEventArgs.cs
- CriticalHandle.cs
- LinqDataSourceValidationException.cs
- TableHeaderCell.cs
- DataGridViewCell.cs
- ResourceSetExpression.cs
- ItemsControl.cs
- RequestCachingSection.cs
- TdsParserStaticMethods.cs
- BindingOperations.cs
- KnownColorTable.cs
- KerberosRequestorSecurityToken.cs
- DataGridViewCell.cs
- RequestQueryParser.cs
- XmlFormatMapping.cs
- DateTime.cs
- CharAnimationBase.cs
- GenericUI.cs
- URL.cs
- __ComObject.cs
- Compiler.cs
- ValidationPropertyAttribute.cs
- InfoCardProofToken.cs
- TextViewBase.cs
- DataGridCell.cs
- LinkGrep.cs
- WebPartHelpVerb.cs
- SizeAnimation.cs
- ClockGroup.cs
- AssemblyCacheEntry.cs
- NameScopePropertyAttribute.cs
- AttachedAnnotation.cs
- TcpClientSocketManager.cs
- QuadTree.cs
- _NetRes.cs
- TextParagraphProperties.cs
- CriticalHandle.cs
- MetadataItem.cs
- IDReferencePropertyAttribute.cs
- SymDocumentType.cs
- LineServicesCallbacks.cs
- SplashScreen.cs
- DiscreteKeyFrames.cs
- DashStyles.cs
- EventBuilder.cs
- NamespaceList.cs
- ConcurrencyMode.cs
- ManagementPath.cs
- SiteOfOriginContainer.cs
- DataGridCellClipboardEventArgs.cs
- storagemappingitemcollection.viewdictionary.cs
- WebPartEventArgs.cs
- EnumerableValidator.cs
- XmlParserContext.cs
- LoginCancelEventArgs.cs
- AspNetHostingPermission.cs
- ConsoleCancelEventArgs.cs
- RegexBoyerMoore.cs
- Parameter.cs
- ProviderConnectionPointCollection.cs
- NotifyIcon.cs
- XmlArrayItemAttributes.cs
- ExpandedWrapper.cs
- StateBag.cs
- WmpBitmapDecoder.cs
- BreadCrumbTextConverter.cs
- UnmanagedMarshal.cs
- ACE.cs
- IIS7UserPrincipal.cs
- SmtpNegotiateAuthenticationModule.cs
- DynamicDataManager.cs
- OdbcParameter.cs
- ProtocolElementCollection.cs
- TextDecoration.cs
- ManifestResourceInfo.cs
- DetailsViewModeEventArgs.cs