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
- UpdateProgress.cs
- SecurityKeyType.cs
- ListParagraph.cs
- ServiceMemoryGates.cs
- SqlCacheDependency.cs
- EventTrigger.cs
- ParseChildrenAsPropertiesAttribute.cs
- ContextDataSourceView.cs
- GeometryDrawing.cs
- PropertyValueUIItem.cs
- NetworkInformationException.cs
- QilReference.cs
- XmlParserContext.cs
- embossbitmapeffect.cs
- InvokeMethod.cs
- ResourceReader.cs
- DataViewManagerListItemTypeDescriptor.cs
- WebPartsPersonalizationAuthorization.cs
- TimerElapsedEvenArgs.cs
- GlobalProxySelection.cs
- InputMethodStateChangeEventArgs.cs
- UnsafeNetInfoNativeMethods.cs
- UTF7Encoding.cs
- TreeViewItem.cs
- ComponentEditorForm.cs
- DataGridViewTextBoxEditingControl.cs
- PropertyEmitter.cs
- AccessDataSourceView.cs
- EndpointInfo.cs
- PromptEventArgs.cs
- FormParameter.cs
- OutputCacheProfile.cs
- WebCategoryAttribute.cs
- Activity.cs
- DataGridColumnsPage.cs
- ZipIOCentralDirectoryFileHeader.cs
- TokenBasedSetEnumerator.cs
- DataGridViewCellConverter.cs
- SqlDependencyUtils.cs
- TextFormatterContext.cs
- _LoggingObject.cs
- If.cs
- PassportAuthenticationModule.cs
- LayoutEngine.cs
- TypedDataSetSchemaImporterExtension.cs
- CopyAction.cs
- BuildManagerHost.cs
- DataGridViewToolTip.cs
- ListViewItemMouseHoverEvent.cs
- EndpointDiscoveryMetadata11.cs
- Speller.cs
- _FtpDataStream.cs
- CompositionAdorner.cs
- WaitHandleCannotBeOpenedException.cs
- MessageTransmitTraceRecord.cs
- ManipulationStartedEventArgs.cs
- Bits.cs
- EventToken.cs
- EntityDataSourceContextCreatingEventArgs.cs
- MissingSatelliteAssemblyException.cs
- TdsParserHelperClasses.cs
- DefaultValueConverter.cs
- diagnosticsswitches.cs
- SemaphoreFullException.cs
- EmptyQuery.cs
- ReadOnlyTernaryTree.cs
- FormsAuthenticationTicket.cs
- followingquery.cs
- TypeBuilderInstantiation.cs
- SchemaNotation.cs
- WebPartVerbsEventArgs.cs
- GatewayDefinition.cs
- BasicBrowserDialog.cs
- DBConcurrencyException.cs
- WebPartConnectionsConfigureVerb.cs
- OracleRowUpdatingEventArgs.cs
- TextTreeTextElementNode.cs
- RemotingServices.cs
- XmlSecureResolver.cs
- GlobalizationAssembly.cs
- ItemCollection.cs
- PersonalizationProvider.cs
- VisualTreeHelper.cs
- ButtonFlatAdapter.cs
- GrowingArray.cs
- ToolBar.cs
- WebControlsSection.cs
- Models.cs
- BidirectionalDictionary.cs
- WaitHandleCannotBeOpenedException.cs
- DesignerProperties.cs
- RichTextBox.cs
- DataControlLinkButton.cs
- ExpressionConverter.cs
- NativeObjectSecurity.cs
- IPAddress.cs
- MarkupCompilePass2.cs
- HttpErrorTraceRecord.cs
- CodeLabeledStatement.cs
- XmlAutoDetectWriter.cs