Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- BackStopAuthenticationModule.cs
- ConsumerConnectionPointCollection.cs
- Constant.cs
- Int32Collection.cs
- EndEvent.cs
- WebPartEditorApplyVerb.cs
- ConditionCollection.cs
- HtmlDocument.cs
- TimelineGroup.cs
- SymDocumentType.cs
- WebBrowserUriTypeConverter.cs
- DragDrop.cs
- WsdlParser.cs
- HttpFileCollection.cs
- OrderByBuilder.cs
- TypedTableBase.cs
- NameValuePair.cs
- ControlType.cs
- LiteralSubsegment.cs
- ClientFormsIdentity.cs
- TextAnchor.cs
- WebPartCatalogCloseVerb.cs
- ChangePassword.cs
- MatrixCamera.cs
- XmlQualifiedName.cs
- StringArrayConverter.cs
- TypeResolver.cs
- Viewport3DVisual.cs
- HyperLink.cs
- FormViewUpdatedEventArgs.cs
- SiteMapDataSourceDesigner.cs
- WeakReadOnlyCollection.cs
- TemplateControlCodeDomTreeGenerator.cs
- AutomationElementIdentifiers.cs
- Accessors.cs
- QuotedStringWriteStateInfo.cs
- InvalidCastException.cs
- ConfigurationLocation.cs
- PropertyDescriptorCollection.cs
- Clock.cs
- ProfileManager.cs
- OperationSelectorBehavior.cs
- handlecollector.cs
- OneToOneMappingSerializer.cs
- DefaultTextStore.cs
- MatchAllMessageFilter.cs
- DiscoveryClientProtocol.cs
- SystemNetHelpers.cs
- SystemDiagnosticsSection.cs
- StateChangeEvent.cs
- GraphicsContext.cs
- TabletCollection.cs
- Token.cs
- ResourceDisplayNameAttribute.cs
- HttpResponseInternalBase.cs
- Container.cs
- PlatformCulture.cs
- RequestNavigateEventArgs.cs
- BamlBinaryReader.cs
- BoundPropertyEntry.cs
- StylusPointPropertyInfoDefaults.cs
- RemoteWebConfigurationHostStream.cs
- InputReportEventArgs.cs
- IssuedTokenClientBehaviorsElementCollection.cs
- XmlImplementation.cs
- RoleManagerSection.cs
- BindingValueChangedEventArgs.cs
- Pair.cs
- ProxyWebPartManager.cs
- DataColumnChangeEvent.cs
- TextParagraphCache.cs
- SafeMarshalContext.cs
- XmlName.cs
- ChildTable.cs
- ContentTextAutomationPeer.cs
- MetadataFile.cs
- WeakRefEnumerator.cs
- DependencyProperty.cs
- SystemIcons.cs
- OleDbCommand.cs
- State.cs
- MetadataArtifactLoaderComposite.cs
- PropertyItem.cs
- TargetInvocationException.cs
- TimelineClockCollection.cs
- NestedContainer.cs
- RemotingSurrogateSelector.cs
- Token.cs
- WindowsFormsDesignerOptionService.cs
- BuildProviderUtils.cs
- IncrementalCompileAnalyzer.cs
- Error.cs
- NavigationProperty.cs
- InstallerTypeAttribute.cs
- WebScriptMetadataMessageEncodingBindingElement.cs
- FieldTemplateFactory.cs
- MessageBox.cs
- AxisAngleRotation3D.cs
- TemplateBindingExtension.cs
- XamlSerializerUtil.cs