Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / WebControls / HorizontalAlignConverter.cs / 1 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ListViewItemSelectionChangedEvent.cs
- OpenFileDialog.cs
- SecurityTokenAuthenticator.cs
- PageParserFilter.cs
- CommonDialog.cs
- CollectionChangedEventManager.cs
- Point4D.cs
- Selection.cs
- OrderByLifter.cs
- GridViewRowPresenter.cs
- COM2TypeInfoProcessor.cs
- DesignerSerializationVisibilityAttribute.cs
- DefaultPrintController.cs
- ScriptingSectionGroup.cs
- JsonCollectionDataContract.cs
- DataControlButton.cs
- BasicExpandProvider.cs
- ReferencedType.cs
- TransformDescriptor.cs
- FontCacheUtil.cs
- DomainLiteralReader.cs
- AttributeTableBuilder.cs
- sitestring.cs
- ImageFormatConverter.cs
- ArglessEventHandlerProxy.cs
- ExpressionParser.cs
- FormViewUpdatedEventArgs.cs
- XmlSchemaComplexContent.cs
- ImageFormat.cs
- DocumentViewerAutomationPeer.cs
- WebPartConnectionsDisconnectVerb.cs
- ComponentSerializationService.cs
- Roles.cs
- CodePropertyReferenceExpression.cs
- FrameworkRichTextComposition.cs
- BindingBase.cs
- PkcsUtils.cs
- InfoCardSymmetricCrypto.cs
- VScrollBar.cs
- DocumentCollection.cs
- DataSourceXmlElementAttribute.cs
- TextEditorCharacters.cs
- ValidationError.cs
- InstanceDataCollection.cs
- ListenerSingletonConnectionReader.cs
- WebConfigurationManager.cs
- StrokeNode.cs
- HttpSysSettings.cs
- ToolStripEditorManager.cs
- ModelItemExtensions.cs
- SqlMethodTransformer.cs
- StringConverter.cs
- DebugInfoExpression.cs
- ToolStripDropTargetManager.cs
- ProxyWebPartConnectionCollection.cs
- ReturnValue.cs
- MethodBuilder.cs
- SubMenuStyleCollection.cs
- SqlUserDefinedTypeAttribute.cs
- MessageHeaderInfoTraceRecord.cs
- SqlInternalConnection.cs
- CharUnicodeInfo.cs
- VoiceChangeEventArgs.cs
- UIElementPropertyUndoUnit.cs
- ReadOnlyCollectionBuilder.cs
- remotingproxy.cs
- dtdvalidator.cs
- CompModSwitches.cs
- Registry.cs
- Messages.cs
- Effect.cs
- Timeline.cs
- DelegateArgumentReference.cs
- Switch.cs
- IPGlobalProperties.cs
- ComboBox.cs
- _HTTPDateParse.cs
- Attributes.cs
- LocatorPartList.cs
- DataSourceConverter.cs
- ObjectParameterCollection.cs
- ObjectDisposedException.cs
- HttpApplication.cs
- FixedPage.cs
- SoapSchemaExporter.cs
- DefaultIfEmptyQueryOperator.cs
- HttpResponseBase.cs
- SwitchDesigner.xaml.cs
- DbConnectionPoolIdentity.cs
- OleDbInfoMessageEvent.cs
- ConfigurationPropertyCollection.cs
- _ListenerRequestStream.cs
- WebPartConnectionsConfigureVerb.cs
- MSHTMLHostUtil.cs
- DataGridTable.cs
- TextTabProperties.cs
- ImageListUtils.cs
- DataGridCell.cs
- FullTextBreakpoint.cs
- ValueProviderWrapper.cs