Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- ManipulationVelocities.cs
- TextStore.cs
- GridProviderWrapper.cs
- GenericsInstances.cs
- CompilationLock.cs
- TraceInternal.cs
- DependencyPropertyChangedEventArgs.cs
- JournalEntryListConverter.cs
- ContextMenuStrip.cs
- PlacementWorkspace.cs
- FamilyTypeface.cs
- WebCategoryAttribute.cs
- XmlDataDocument.cs
- CodeTypeParameter.cs
- CompareValidator.cs
- InternalTypeHelper.cs
- InkCanvasSelectionAdorner.cs
- NaturalLanguageHyphenator.cs
- DataGridViewAccessibleObject.cs
- ObjectStateManager.cs
- BlockExpression.cs
- QueryableDataSourceView.cs
- StrokeSerializer.cs
- FillErrorEventArgs.cs
- ProviderConnectionPoint.cs
- UserPreferenceChangingEventArgs.cs
- SubclassTypeValidatorAttribute.cs
- diagnosticsswitches.cs
- ApplicationServiceManager.cs
- ZipIOExtraFieldElement.cs
- SafeLibraryHandle.cs
- StandardCommands.cs
- ComplexTypeEmitter.cs
- ContainerSelectorBehavior.cs
- WriteStateInfoBase.cs
- Matrix.cs
- ValidatingPropertiesEventArgs.cs
- QueryContinueDragEventArgs.cs
- PageBreakRecord.cs
- RawMouseInputReport.cs
- ItemContainerPattern.cs
- BinaryUtilClasses.cs
- SchemaNotation.cs
- UnhandledExceptionEventArgs.cs
- CollectionBuilder.cs
- TransactionTraceIdentifier.cs
- EventRouteFactory.cs
- SafeNativeHandle.cs
- HtmlMeta.cs
- Path.cs
- LowerCaseStringConverter.cs
- PolicyVersionConverter.cs
- MatrixTransform3D.cs
- TemplateLookupAction.cs
- IdentityElement.cs
- AcceleratedTokenProvider.cs
- UpdateInfo.cs
- Formatter.cs
- DesignerImageAdapter.cs
- GridLengthConverter.cs
- AutoCompleteStringCollection.cs
- Size3DConverter.cs
- WebSysDefaultValueAttribute.cs
- ByteConverter.cs
- Equal.cs
- InstanceStore.cs
- OdbcPermission.cs
- SerializableAttribute.cs
- SQLInt32.cs
- HotCommands.cs
- OfTypeExpression.cs
- SiteMapProvider.cs
- CodeMemberProperty.cs
- WindowProviderWrapper.cs
- TabControlCancelEvent.cs
- AuthorizationPolicyTypeElementCollection.cs
- FormViewPageEventArgs.cs
- CompilerInfo.cs
- TraceListener.cs
- WebPartManagerInternals.cs
- MarshalDirectiveException.cs
- SafeEventHandle.cs
- Rules.cs
- DataSet.cs
- WindowsSpinner.cs
- Identity.cs
- SQLInt16Storage.cs
- DataGridPageChangedEventArgs.cs
- CodeAttachEventStatement.cs
- OdbcParameterCollection.cs
- XmlHierarchicalDataSourceView.cs
- TextRange.cs
- KnownTypesHelper.cs
- ContentPosition.cs
- NavigateEvent.cs
- Debugger.cs
- FlowDocumentPageViewerAutomationPeer.cs
- SortQuery.cs
- DocumentSequenceHighlightLayer.cs
- SystemIPGlobalStatistics.cs