Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- Color.cs
- CustomCredentialPolicy.cs
- LayoutTable.cs
- BitmapDecoder.cs
- SchemaTableColumn.cs
- GridViewItemAutomationPeer.cs
- Util.cs
- ListBoxItem.cs
- ResourceContainer.cs
- BitmapFrameEncode.cs
- HMACSHA512.cs
- ExpressionsCollectionEditor.cs
- TextEmbeddedObject.cs
- MobileTemplatedControlDesigner.cs
- IMembershipProvider.cs
- UnionCodeGroup.cs
- SystemUnicastIPAddressInformation.cs
- ObjectPersistData.cs
- _StreamFramer.cs
- TextModifierScope.cs
- DbParameterCollectionHelper.cs
- DSACryptoServiceProvider.cs
- SoapAttributes.cs
- PageContent.cs
- ReferenceTypeElement.cs
- BehaviorEditorPart.cs
- PiiTraceSource.cs
- FormsAuthenticationUser.cs
- RegisteredHiddenField.cs
- GroupedContextMenuStrip.cs
- _ProxyChain.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- HierarchicalDataSourceControl.cs
- SupportsEventValidationAttribute.cs
- EventLogPermission.cs
- CodeExpressionCollection.cs
- SafeNativeMethodsOther.cs
- SerializationObjectManager.cs
- ObjectItemAttributeAssemblyLoader.cs
- StreamFormatter.cs
- RequiredAttributeAttribute.cs
- safelinkcollection.cs
- BinaryQueryOperator.cs
- SQLInt16.cs
- MenuAutomationPeer.cs
- ProfileGroupSettings.cs
- WebControlAdapter.cs
- ListViewTableCell.cs
- X509RawDataKeyIdentifierClause.cs
- PanelContainerDesigner.cs
- ElementsClipboardData.cs
- PriorityBindingExpression.cs
- loginstatus.cs
- ThreadPool.cs
- SEHException.cs
- CodeObject.cs
- LinearKeyFrames.cs
- CapabilitiesSection.cs
- NullableIntMinMaxAggregationOperator.cs
- RecordsAffectedEventArgs.cs
- Operand.cs
- StandardTransformFactory.cs
- SupportingTokenParameters.cs
- Win32.cs
- RepeatButton.cs
- MatrixKeyFrameCollection.cs
- IPAddress.cs
- EntityException.cs
- BaseCodeDomTreeGenerator.cs
- SafeReadContext.cs
- DataErrorValidationRule.cs
- RawStylusActions.cs
- PinnedBufferMemoryStream.cs
- SHA512Managed.cs
- InstanceNameConverter.cs
- TouchEventArgs.cs
- CodeMemberField.cs
- ServiceHost.cs
- PaintEvent.cs
- ListView.cs
- ExceptionValidationRule.cs
- InternalResources.cs
- ClientApiGenerator.cs
- BlurBitmapEffect.cs
- DataGridViewCellStyleConverter.cs
- VariantWrapper.cs
- ProviderSettings.cs
- _NestedMultipleAsyncResult.cs
- WindowsGraphicsWrapper.cs
- EventMap.cs
- PrimitiveDataContract.cs
- Hashtable.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- XmlQueryCardinality.cs
- DataRelationCollection.cs
- AttachmentService.cs
- Win32NamedPipes.cs
- isolationinterop.cs
- ConnectionManager.cs
- MergeLocalizationDirectives.cs