Code:
/ FX-1434 / FX-1434 / 1.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
- RemoteDebugger.cs
- _DomainName.cs
- ThrowOnMultipleAssignment.cs
- WindowsListViewItemStartMenu.cs
- WizardStepBase.cs
- Icon.cs
- DataListCommandEventArgs.cs
- TextTreePropertyUndoUnit.cs
- ColorContextHelper.cs
- SchemaHelper.cs
- QueryReaderSettings.cs
- Marshal.cs
- DmlSqlGenerator.cs
- SerializerWriterEventHandlers.cs
- NativeRightsManagementAPIsStructures.cs
- TextEffectResolver.cs
- QueryStringParameter.cs
- SiteMapDataSourceDesigner.cs
- ServiceObjectContainer.cs
- CalendarDesigner.cs
- DefaultAutoFieldGenerator.cs
- TextElementCollection.cs
- SafeBuffer.cs
- DiscoveryClientChannelFactory.cs
- DesignerView.cs
- BitmapEffectGeneralTransform.cs
- ListControlActionList.cs
- StructuralObject.cs
- XmlQualifiedNameTest.cs
- httpstaticobjectscollection.cs
- odbcmetadatacollectionnames.cs
- HtmlImage.cs
- SQlBooleanStorage.cs
- RegistrySecurity.cs
- XmlProcessingInstruction.cs
- BackEase.cs
- ItemsControlAutomationPeer.cs
- SettingsPropertyIsReadOnlyException.cs
- AdPostCacheSubstitution.cs
- GeometryModel3D.cs
- StringSource.cs
- CacheMemory.cs
- SortedDictionary.cs
- ValueQuery.cs
- NumberFormatInfo.cs
- XPathMultyIterator.cs
- CheckedPointers.cs
- CombinedGeometry.cs
- BmpBitmapEncoder.cs
- LinkDescriptor.cs
- WebPartConnectionsConfigureVerb.cs
- EdmEntityTypeAttribute.cs
- EventMappingSettings.cs
- PartialToken.cs
- ByteStorage.cs
- TreeNodeBinding.cs
- CapacityStreamGeometryContext.cs
- EncodingStreamWrapper.cs
- CodeTypeReferenceCollection.cs
- DictionarySectionHandler.cs
- HttpCookie.cs
- RenderData.cs
- ObjectHandle.cs
- NativeMethods.cs
- CssStyleCollection.cs
- GenericAuthenticationEventArgs.cs
- RectConverter.cs
- ResourcePermissionBaseEntry.cs
- KeyValueSerializer.cs
- HttpRequestCacheValidator.cs
- DocumentGridPage.cs
- HMACRIPEMD160.cs
- HelpProvider.cs
- ContextActivityUtils.cs
- XmlValidatingReaderImpl.cs
- TagPrefixCollection.cs
- Pen.cs
- ConstantCheck.cs
- TreeNodeStyleCollection.cs
- PriorityBinding.cs
- CollectionDataContract.cs
- JoinCqlBlock.cs
- EnumerableRowCollection.cs
- RawStylusInput.cs
- DocumentReferenceCollection.cs
- BitStack.cs
- FileSystemInfo.cs
- bidPrivateBase.cs
- MapPathBasedVirtualPathProvider.cs
- XhtmlBasicSelectionListAdapter.cs
- DataControlPagerLinkButton.cs
- FormatConvertedBitmap.cs
- ToolStripItemTextRenderEventArgs.cs
- MessageFilterException.cs
- TextEditorLists.cs
- ConfigurationValues.cs
- LayoutExceptionEventArgs.cs
- RSAPKCS1KeyExchangeFormatter.cs
- TypeTypeConverter.cs
- DeferrableContent.cs