Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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. // //----------------------------------------------------------------------------- // 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InkCanvasFeedbackAdorner.cs
- PathGeometry.cs
- CharacterMetrics.cs
- Opcode.cs
- WrapPanel.cs
- StrokeCollection.cs
- WinEventTracker.cs
- RSAProtectedConfigurationProvider.cs
- BroadcastEventHelper.cs
- PropertyValueUIItem.cs
- PassportAuthentication.cs
- CellParaClient.cs
- UnsafeMethods.cs
- StyleSheet.cs
- ProcessHostMapPath.cs
- latinshape.cs
- ClientTargetCollection.cs
- RowToFieldTransformer.cs
- ConfigurationSettings.cs
- Int32Animation.cs
- precedingquery.cs
- DrawListViewColumnHeaderEventArgs.cs
- LayoutEngine.cs
- SqlConnectionString.cs
- SqlGenerator.cs
- MessageDecoder.cs
- DataGridViewCellParsingEventArgs.cs
- StandardCommands.cs
- CellPartitioner.cs
- WorkflowServiceOperationListItem.cs
- TimelineCollection.cs
- HtmlControlAdapter.cs
- SoapAttributeOverrides.cs
- RecognizeCompletedEventArgs.cs
- PageSettings.cs
- CreateSequence.cs
- CapabilitiesRule.cs
- FactoryRecord.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- DmlSqlGenerator.cs
- DataGridViewControlCollection.cs
- EncoderBestFitFallback.cs
- CapabilitiesAssignment.cs
- ConfigViewGenerator.cs
- ColorAnimationUsingKeyFrames.cs
- ActivitySurrogate.cs
- ServiceDocument.cs
- TypeKeyValue.cs
- DbResourceAllocator.cs
- MimeWriter.cs
- DispatcherTimer.cs
- ViewStateModeByIdAttribute.cs
- HTMLTagNameToTypeMapper.cs
- DataGridClipboardHelper.cs
- Button.cs
- InternalReceiveMessage.cs
- MemberPath.cs
- GridViewDeletedEventArgs.cs
- ResourceDictionaryCollection.cs
- SimpleTypeResolver.cs
- WindowsTreeView.cs
- EditorServiceContext.cs
- WebSysDescriptionAttribute.cs
- ReadingWritingEntityEventArgs.cs
- ICollection.cs
- UserNameSecurityToken.cs
- HyperLinkStyle.cs
- ListCollectionView.cs
- NativeStructs.cs
- Privilege.cs
- Cell.cs
- CopyCodeAction.cs
- X509Certificate.cs
- PeerContact.cs
- AggregateNode.cs
- UIElementPropertyUndoUnit.cs
- QueryContext.cs
- FragmentQueryProcessor.cs
- DateTimeConstantAttribute.cs
- TdsParserStaticMethods.cs
- FormClosingEvent.cs
- DCSafeHandle.cs
- Stopwatch.cs
- FtpCachePolicyElement.cs
- SamlConstants.cs
- AxImporter.cs
- StatusBar.cs
- PowerStatus.cs
- DotAtomReader.cs
- FrugalList.cs
- PenLineCapValidation.cs
- NumericPagerField.cs
- SqlWebEventProvider.cs
- ProviderSettings.cs
- StrokeNodeOperations2.cs
- DetailsViewInsertEventArgs.cs
- HttpsChannelFactory.cs
- StatusBarItemAutomationPeer.cs
- Hex.cs
- AdjustableArrowCap.cs