Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / HorizontalAlignConverter.cs / 1305376 / HorizontalAlignConverter.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 HorizontalAlignConverter : EnumConverter { static string[] stringValues = new String[(int) HorizontalAlign.Justify + 1]; static HorizontalAlignConverter () { stringValues[(int) HorizontalAlign.NotSet] = "NotSet"; stringValues[(int) HorizontalAlign.Left] = "Left"; stringValues[(int) HorizontalAlign.Center] = "Center"; stringValues[(int) HorizontalAlign.Right] = "Right"; stringValues[(int) HorizontalAlign.Justify] = "Justify"; } // 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 HorizontalAlignConverter () : base(typeof(HorizontalAlign)) {} 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 HorizontalAlign.NotSet; switch (textValue) { case "NotSet": return HorizontalAlign.NotSet; case "Left": return HorizontalAlign.Left; case "Center": return HorizontalAlign.Center; case "Right": return HorizontalAlign.Right; case "Justify": return HorizontalAlign.Justify; } } 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)HorizontalAlign.Justify)) { 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 HorizontalAlignConverter : EnumConverter { static string[] stringValues = new String[(int) HorizontalAlign.Justify + 1]; static HorizontalAlignConverter () { stringValues[(int) HorizontalAlign.NotSet] = "NotSet"; stringValues[(int) HorizontalAlign.Left] = "Left"; stringValues[(int) HorizontalAlign.Center] = "Center"; stringValues[(int) HorizontalAlign.Right] = "Right"; stringValues[(int) HorizontalAlign.Justify] = "Justify"; } // 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 HorizontalAlignConverter () : base(typeof(HorizontalAlign)) {} 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 HorizontalAlign.NotSet; switch (textValue) { case "NotSet": return HorizontalAlign.NotSet; case "Left": return HorizontalAlign.Left; case "Center": return HorizontalAlign.Center; case "Right": return HorizontalAlign.Right; case "Justify": return HorizontalAlign.Justify; } } 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)HorizontalAlign.Justify)) { 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
- Pkcs9Attribute.cs
- EventHandlerList.cs
- invalidudtexception.cs
- ZipIOFileItemStream.cs
- CaseInsensitiveHashCodeProvider.cs
- HtmlListAdapter.cs
- InputScopeConverter.cs
- ToolStripEditorManager.cs
- WebPartVerbCollection.cs
- BasicBrowserDialog.designer.cs
- DataView.cs
- ObjectHelper.cs
- TextRenderer.cs
- CommonGetThemePartSize.cs
- ServiceDeploymentInfo.cs
- ItemCollectionEditor.cs
- UnsafeCollabNativeMethods.cs
- DynamicFilterExpression.cs
- SQLDouble.cs
- AdPostCacheSubstitution.cs
- StringToken.cs
- MultipleFilterMatchesException.cs
- SaveFileDialog.cs
- FileDialog_Vista_Interop.cs
- VisualCollection.cs
- ProcessInputEventArgs.cs
- HasCopySemanticsAttribute.cs
- SQLResource.cs
- EventLog.cs
- HttpWebRequest.cs
- Exception.cs
- EventWaitHandle.cs
- BypassElement.cs
- SafeFindHandle.cs
- AssemblyCollection.cs
- Base64Decoder.cs
- PassportPrincipal.cs
- CollectionViewProxy.cs
- Tile.cs
- BindValidationContext.cs
- UriTemplateTrieNode.cs
- RestClientProxyHandler.cs
- COM2Properties.cs
- TrackingStringDictionary.cs
- BlurBitmapEffect.cs
- BaseParser.cs
- PseudoWebRequest.cs
- DataObjectCopyingEventArgs.cs
- XmlSerializerVersionAttribute.cs
- ConfigurationValidatorAttribute.cs
- SqlWorkflowPersistenceService.cs
- CryptographicAttribute.cs
- JapaneseLunisolarCalendar.cs
- TraceHwndHost.cs
- ObjectQuery_EntitySqlExtensions.cs
- SoundPlayerAction.cs
- invalidudtexception.cs
- SQLBinary.cs
- BuildProvider.cs
- FlowDocumentPageViewerAutomationPeer.cs
- HtmlMeta.cs
- BinaryObjectReader.cs
- FileDialog.cs
- SimpleWebHandlerParser.cs
- Rotation3DAnimation.cs
- EntityDataSourceDesignerHelper.cs
- XmlSerializationReader.cs
- CaseInsensitiveComparer.cs
- DetailsViewCommandEventArgs.cs
- WebPartDescription.cs
- TextPointer.cs
- ConfigXmlComment.cs
- UserMapPath.cs
- WindowsClaimSet.cs
- DataBindingCollection.cs
- PriorityRange.cs
- FastEncoder.cs
- CounterSampleCalculator.cs
- PhysicalFontFamily.cs
- CultureInfoConverter.cs
- RsaSecurityToken.cs
- DataObjectAttribute.cs
- ConnectorDragDropGlyph.cs
- GradientBrush.cs
- IItemContainerGenerator.cs
- HttpCapabilitiesEvaluator.cs
- ProfileInfo.cs
- BindingNavigator.cs
- TagNameToTypeMapper.cs
- CopyOfAction.cs
- ObjectTag.cs
- TransactionCache.cs
- ImageCodecInfoPrivate.cs
- X509ServiceCertificateAuthenticationElement.cs
- DocumentsTrace.cs
- ToolStripStatusLabel.cs
- OracleBFile.cs
- SoapEnumAttribute.cs
- SHA1CryptoServiceProvider.cs
- ButtonBase.cs