Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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. // //----------------------------------------------------------------------------- // 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
- MonthChangedEventArgs.cs
- DataTablePropertyDescriptor.cs
- StorageEntityContainerMapping.cs
- CodeChecksumPragma.cs
- PageClientProxyGenerator.cs
- ResXResourceSet.cs
- SelectionPattern.cs
- RemoteWebConfigurationHost.cs
- XslTransformFileEditor.cs
- EventProviderWriter.cs
- XmlNamespaceMappingCollection.cs
- Focus.cs
- ToolStripItemClickedEventArgs.cs
- PenThreadWorker.cs
- ValueQuery.cs
- LogFlushAsyncResult.cs
- GeneralTransform3DCollection.cs
- EdmMember.cs
- ExcCanonicalXml.cs
- CompressStream.cs
- SimpleMailWebEventProvider.cs
- OleStrCAMarshaler.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- Marshal.cs
- CursorConverter.cs
- ListControl.cs
- ReadWriteControlDesigner.cs
- SqlDataSourceRefreshSchemaForm.cs
- SolidColorBrush.cs
- DictionaryEntry.cs
- ClientUrlResolverWrapper.cs
- AudioDeviceOut.cs
- BinHexDecoder.cs
- SymmetricKey.cs
- HwndKeyboardInputProvider.cs
- XamlParser.cs
- FontStyles.cs
- MemberNameValidator.cs
- EventBuilder.cs
- _CookieModule.cs
- DecoderReplacementFallback.cs
- Menu.cs
- ConfigXmlCDataSection.cs
- AlphaSortedEnumConverter.cs
- sqlcontext.cs
- GlobalItem.cs
- UxThemeWrapper.cs
- WebContext.cs
- ChannelBinding.cs
- PersonalizationEntry.cs
- CaseInsensitiveOrdinalStringComparer.cs
- XmlSchemaSimpleContentExtension.cs
- PublisherMembershipCondition.cs
- RequestChannelBinder.cs
- UnitControl.cs
- TextParagraph.cs
- XmlDataImplementation.cs
- EntityStoreSchemaFilterEntry.cs
- ListBindableAttribute.cs
- InertiaTranslationBehavior.cs
- DrawItemEvent.cs
- NamespaceMapping.cs
- MouseWheelEventArgs.cs
- UInt64.cs
- DataSetUtil.cs
- Binding.cs
- RoamingStoreFileUtility.cs
- DrawingGroup.cs
- SizeConverter.cs
- BinaryObjectWriter.cs
- ISO2022Encoding.cs
- EncoderParameters.cs
- Switch.cs
- followingsibling.cs
- UTF32Encoding.cs
- DownloadProgressEventArgs.cs
- UnmanagedMemoryStream.cs
- HttpClientCertificate.cs
- SelectionRangeConverter.cs
- CodeAccessSecurityEngine.cs
- Types.cs
- HtmlShim.cs
- MarginsConverter.cs
- PerspectiveCamera.cs
- _HeaderInfo.cs
- LogWriteRestartAreaState.cs
- BrowserDefinition.cs
- WmlPageAdapter.cs
- XmlSchema.cs
- ClientTargetSection.cs
- ManagedFilter.cs
- ArraySubsetEnumerator.cs
- SqlPersistenceProviderFactory.cs
- SamlAdvice.cs
- DashStyles.cs
- TextElementEditingBehaviorAttribute.cs
- HttpUnhandledOperationInvoker.cs
- SafeNativeMethods.cs
- ColorMap.cs
- CallbackHandler.cs