Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- DrawingCollection.cs
- TimersDescriptionAttribute.cs
- SqlProfileProvider.cs
- SignatureDescription.cs
- ProjectionPathBuilder.cs
- Config.cs
- PropertyFilterAttribute.cs
- SqlGatherConsumedAliases.cs
- TextEffect.cs
- AsymmetricAlgorithm.cs
- CompilerInfo.cs
- FieldNameLookup.cs
- EtwTrace.cs
- UriPrefixTable.cs
- SchemaCreator.cs
- ApplicationTrust.cs
- ChildDocumentBlock.cs
- WebRequest.cs
- UnsafeNativeMethodsCLR.cs
- LoginUtil.cs
- PriorityBinding.cs
- WindowsSlider.cs
- ISAPIApplicationHost.cs
- RadioButton.cs
- Activity.cs
- Parser.cs
- ValidationErrorCollection.cs
- RegexGroup.cs
- EditorPart.cs
- StylusSystemGestureEventArgs.cs
- AuthenticationModulesSection.cs
- CombinedGeometry.cs
- HyperLink.cs
- InitializationEventAttribute.cs
- ServiceManagerHandle.cs
- HtmlInputControl.cs
- AuthenticationConfig.cs
- Timer.cs
- ObjectMemberMapping.cs
- ExpressionBuilder.cs
- ExpressionBindings.cs
- SamlAdvice.cs
- HwndSourceParameters.cs
- DataGridViewLinkColumn.cs
- ImageAnimator.cs
- ColorPalette.cs
- DecoratedNameAttribute.cs
- DoubleLink.cs
- WebPartZoneCollection.cs
- cryptoapiTransform.cs
- XamlBrushSerializer.cs
- MetaDataInfo.cs
- XmlChoiceIdentifierAttribute.cs
- COM2PropertyDescriptor.cs
- TokenBasedSet.cs
- ArrayElementGridEntry.cs
- TextBox.cs
- WinEventHandler.cs
- TextCharacters.cs
- FormView.cs
- SqlStream.cs
- ButtonChrome.cs
- BitmapMetadataEnumerator.cs
- Pens.cs
- SqlLiftIndependentRowExpressions.cs
- DataGridViewCellValidatingEventArgs.cs
- ViewStateException.cs
- EntitySetDataBindingList.cs
- CopyCodeAction.cs
- MissingSatelliteAssemblyException.cs
- UITypeEditor.cs
- GridViewColumnHeader.cs
- Range.cs
- ArraySortHelper.cs
- PageParserFilter.cs
- GridViewSelectEventArgs.cs
- UdpDuplexChannel.cs
- ClientSettingsProvider.cs
- LoadedEvent.cs
- ViewKeyConstraint.cs
- LongValidatorAttribute.cs
- CodeMethodReturnStatement.cs
- DiscoveryInnerClientManaged11.cs
- IApplicationTrustManager.cs
- XmlTextWriter.cs
- SelectionProviderWrapper.cs
- ISFClipboardData.cs
- DataObjectPastingEventArgs.cs
- SoapAttributeAttribute.cs
- EventItfInfo.cs
- peernodeimplementation.cs
- SingleConverter.cs
- SQLBinaryStorage.cs
- SafeHandles.cs
- XmlDownloadManager.cs
- SafeThreadHandle.cs
- MimeMapping.cs
- XmlObjectSerializerReadContextComplex.cs
- TraceContextRecord.cs
- ExponentialEase.cs