Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ObjectTag.cs
- DataControlFieldCell.cs
- FormsIdentity.cs
- TextFormatterHost.cs
- BaseDataBoundControl.cs
- AuthenticationModuleElement.cs
- CompositeScriptReference.cs
- DispatcherHooks.cs
- SqlFunctionAttribute.cs
- xmlNames.cs
- Globals.cs
- Animatable.cs
- LoadedOrUnloadedOperation.cs
- CodeArrayIndexerExpression.cs
- PackageDigitalSignatureManager.cs
- SafeNativeMethods.cs
- XhtmlCssHandler.cs
- Queue.cs
- HttpFileCollection.cs
- BoolLiteral.cs
- WebSysDefaultValueAttribute.cs
- UriTemplatePathSegment.cs
- XsltOutput.cs
- ServiceMemoryGates.cs
- TransformConverter.cs
- ValueUnavailableException.cs
- HandlerBase.cs
- DataViewSetting.cs
- AddingNewEventArgs.cs
- XsltException.cs
- DataGrid.cs
- sortedlist.cs
- MetadataLocation.cs
- Accessible.cs
- TreeNode.cs
- PropertyOverridesTypeEditor.cs
- TableLayoutStyleCollection.cs
- CommandConverter.cs
- WebPartCancelEventArgs.cs
- PromptEventArgs.cs
- CodeCastExpression.cs
- SingleResultAttribute.cs
- InitializationEventAttribute.cs
- input.cs
- StateInitializationDesigner.cs
- IgnoreFileBuildProvider.cs
- XmlEncodedRawTextWriter.cs
- TemplateControlCodeDomTreeGenerator.cs
- WebServiceParameterData.cs
- UnregisterInfo.cs
- TimeZone.cs
- OdbcError.cs
- FlowPosition.cs
- AttributeSetAction.cs
- ExternalDataExchangeService.cs
- PassportAuthenticationModule.cs
- XmlNodeChangedEventArgs.cs
- IndentedWriter.cs
- UserPersonalizationStateInfo.cs
- ActiveXHelper.cs
- CoTaskMemSafeHandle.cs
- SystemWebSectionGroup.cs
- ListBox.cs
- ChameleonKey.cs
- SchemaTypeEmitter.cs
- RowTypePropertyElement.cs
- ContentPathSegment.cs
- XmlSchema.cs
- SequenceDesignerAccessibleObject.cs
- PageCatalogPartDesigner.cs
- HashCodeCombiner.cs
- RayMeshGeometry3DHitTestResult.cs
- DisableDpiAwarenessAttribute.cs
- _DynamicWinsockMethods.cs
- SynchronizationFilter.cs
- HtmlSelect.cs
- _ContextAwareResult.cs
- FrameSecurityDescriptor.cs
- TemplateGroupCollection.cs
- LinkLabel.cs
- MiniCustomAttributeInfo.cs
- WebScriptMetadataFormatter.cs
- CollectionExtensions.cs
- HtmlTable.cs
- DataSourceGroupCollection.cs
- SettingsSection.cs
- NestedContainer.cs
- DiagnosticTraceSource.cs
- StartFileNameEditor.cs
- TypeBuilderInstantiation.cs
- XmlValidatingReaderImpl.cs
- RootNamespaceAttribute.cs
- FrameworkContentElement.cs
- RegexTree.cs
- DataGridColumnHeaderItemAutomationPeer.cs
- PolyLineSegmentFigureLogic.cs
- RequestUriProcessor.cs
- PropertyValueChangedEvent.cs
- PopupRootAutomationPeer.cs
- DoubleStorage.cs