Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CompilerCollection.cs
- XsltFunctions.cs
- ZoneMembershipCondition.cs
- TextTreeUndo.cs
- StrokeNode.cs
- BindingContext.cs
- SafeCryptoHandles.cs
- IndexOutOfRangeException.cs
- ToolboxItemFilterAttribute.cs
- GridViewDeletedEventArgs.cs
- DataServiceExpressionVisitor.cs
- DropTarget.cs
- EntryPointNotFoundException.cs
- ReadOnlyMetadataCollection.cs
- SmiConnection.cs
- MessageBox.cs
- ExtensionDataObject.cs
- ConnectionStringsExpressionBuilder.cs
- UpdatePanelControlTrigger.cs
- UrlAuthorizationModule.cs
- MessageSmuggler.cs
- JsonXmlDataContract.cs
- DocumentPage.cs
- CacheChildrenQuery.cs
- RemotingException.cs
- RuntimeTrackingProfile.cs
- EnumValidator.cs
- RefExpr.cs
- DescendantBaseQuery.cs
- FixedDSBuilder.cs
- _ConnectStream.cs
- EventMap.cs
- BitmapEffectDrawingContent.cs
- StyleTypedPropertyAttribute.cs
- Command.cs
- EventSinkHelperWriter.cs
- DataControlFieldCollection.cs
- DataGridViewColumnStateChangedEventArgs.cs
- XmlQualifiedName.cs
- PriorityQueue.cs
- M3DUtil.cs
- SignatureDescription.cs
- JournalEntry.cs
- ViewStateModeByIdAttribute.cs
- SmiEventSink.cs
- KeyEvent.cs
- SmiContext.cs
- BatchParser.cs
- TargetInvocationException.cs
- IdleTimeoutMonitor.cs
- Sentence.cs
- SmiMetaDataProperty.cs
- GenericPrincipal.cs
- MissingManifestResourceException.cs
- SiteMapProvider.cs
- DataSourceCacheDurationConverter.cs
- HttpRequest.cs
- SharedDp.cs
- RootProfilePropertySettingsCollection.cs
- OdbcRowUpdatingEvent.cs
- BindingFormattingDialog.cs
- ListViewContainer.cs
- FlatButtonAppearance.cs
- Pens.cs
- Compiler.cs
- TimelineGroup.cs
- latinshape.cs
- ComponentResourceManager.cs
- SmtpSection.cs
- DataGridPageChangedEventArgs.cs
- TraceUtility.cs
- GridView.cs
- storepermission.cs
- CommonObjectSecurity.cs
- ProfileService.cs
- SqlServices.cs
- ProcessThread.cs
- PeerTransportBindingElement.cs
- KeyMatchBuilder.cs
- DataControlFieldTypeEditor.cs
- NativeMethods.cs
- UnsafeNativeMethods.cs
- ManagementDateTime.cs
- Int32.cs
- ChangeInterceptorAttribute.cs
- ScriptingJsonSerializationSection.cs
- sortedlist.cs
- SaveFileDialog.cs
- FormatterServicesNoSerializableCheck.cs
- EntityProviderFactory.cs
- ColorConverter.cs
- DBConcurrencyException.cs
- GlyphCache.cs
- ContainerParaClient.cs
- TimeoutValidationAttribute.cs
- HttpConfigurationSystem.cs
- IntSumAggregationOperator.cs
- FontStyleConverter.cs
- MimeWriter.cs
- OleDbConnectionInternal.cs