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
- ApplicationFileParser.cs
- Point3DCollection.cs
- HtmlTextArea.cs
- messageonlyhwndwrapper.cs
- XmlSerializerOperationBehavior.cs
- PersianCalendar.cs
- FileSystemInfo.cs
- DbBuffer.cs
- XmlName.cs
- ValidationSummary.cs
- SafeNativeMethodsCLR.cs
- SourceChangedEventArgs.cs
- SqlFileStream.cs
- ButtonFlatAdapter.cs
- EventLogEntryCollection.cs
- ActivityExecutionWorkItem.cs
- SmiXetterAccessMap.cs
- MessageEventSubscriptionService.cs
- StrokeDescriptor.cs
- DataGridViewTextBoxColumn.cs
- ContractMapping.cs
- ActivityWithResultValueSerializer.cs
- InteropTrackingRecord.cs
- RSAOAEPKeyExchangeFormatter.cs
- PermissionRequestEvidence.cs
- SupportsEventValidationAttribute.cs
- PresentationTraceSources.cs
- SecurityMode.cs
- DataSourceView.cs
- MatrixTransform.cs
- RootBrowserWindowAutomationPeer.cs
- InboundActivityHelper.cs
- SerialReceived.cs
- Rfc2898DeriveBytes.cs
- Viewport2DVisual3D.cs
- TextOutput.cs
- NullReferenceException.cs
- WizardSideBarListControlItemEventArgs.cs
- ResourceManager.cs
- ManifestBasedResourceGroveler.cs
- assemblycache.cs
- BypassElementCollection.cs
- InputDevice.cs
- PolicyStatement.cs
- EndOfStreamException.cs
- FrameworkElement.cs
- XmlWrappingWriter.cs
- WebBrowserBase.cs
- XmlEntity.cs
- MinimizableAttributeTypeConverter.cs
- UserPreferenceChangingEventArgs.cs
- Int16Storage.cs
- MenuItem.cs
- GridViewRowPresenterBase.cs
- ExceptionCollection.cs
- SHA256.cs
- UserPreferenceChangedEventArgs.cs
- LogicalExpressionTypeConverter.cs
- MgmtConfigurationRecord.cs
- FormView.cs
- WindowInteractionStateTracker.cs
- TextSpan.cs
- WebPartTransformerCollection.cs
- NetDataContractSerializer.cs
- CustomValidator.cs
- SimpleHandlerFactory.cs
- ProfileService.cs
- SystemIPGlobalProperties.cs
- XmlCharType.cs
- QuadraticBezierSegment.cs
- DataGridViewCellCollection.cs
- SoapFormatterSinks.cs
- CommandManager.cs
- FontNameConverter.cs
- ProviderIncompatibleException.cs
- tibetanshape.cs
- AssemblyCollection.cs
- ProxyFragment.cs
- CapabilitiesAssignment.cs
- TearOffProxy.cs
- CopyAction.cs
- HandlerMappingMemo.cs
- TrackingConditionCollection.cs
- UnsafeNativeMethods.cs
- TabletCollection.cs
- PagedDataSource.cs
- x509store.cs
- XPathArrayIterator.cs
- ModulesEntry.cs
- ToolStripPanelDesigner.cs
- FixedDocument.cs
- SerializationTrace.cs
- LongAverageAggregationOperator.cs
- XmlSchemaSimpleTypeUnion.cs
- LogicalExpr.cs
- ToolStripPanelCell.cs
- OrderPreservingPipeliningSpoolingTask.cs
- InputLanguageCollection.cs
- Rectangle.cs
- EditableRegion.cs