Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OleDbConnectionPoolGroupProviderInfo.cs
- TrackingServices.cs
- EntityDataReader.cs
- AspCompat.cs
- SchemaElementDecl.cs
- QueryableDataSourceHelper.cs
- TextHidden.cs
- RelAssertionDirectKeyIdentifierClause.cs
- SqlParameterizer.cs
- COM2ExtendedTypeConverter.cs
- DragDeltaEventArgs.cs
- InitializingNewItemEventArgs.cs
- EditorPart.cs
- XmlSchemaAnnotation.cs
- ContainerFilterService.cs
- MsmqReceiveParameters.cs
- XmlBaseReader.cs
- SafeProcessHandle.cs
- SafeArrayTypeMismatchException.cs
- ModifierKeysConverter.cs
- ObjectAssociationEndMapping.cs
- GridViewItemAutomationPeer.cs
- WpfXamlType.cs
- MatrixConverter.cs
- RadioButtonFlatAdapter.cs
- ToolStripGripRenderEventArgs.cs
- BindingSource.cs
- Drawing.cs
- ObjectViewListener.cs
- RelationshipDetailsCollection.cs
- InvokePatternIdentifiers.cs
- DataRelation.cs
- SafeNativeMethodsCLR.cs
- DeleteIndexBinder.cs
- SafeNativeMethodsMilCoreApi.cs
- UTF7Encoding.cs
- AsyncResult.cs
- CurrentChangingEventManager.cs
- HttpStaticObjectsCollectionWrapper.cs
- PtsHelper.cs
- ContainerParaClient.cs
- Point3DCollection.cs
- SqlParameter.cs
- FixedPageAutomationPeer.cs
- ProviderConnectionPoint.cs
- NameSpaceExtractor.cs
- CounterCreationDataConverter.cs
- SingleQueryOperator.cs
- _IPv4Address.cs
- InvalidContentTypeException.cs
- SoapRpcMethodAttribute.cs
- TargetControlTypeAttribute.cs
- ProfessionalColors.cs
- SqlTriggerContext.cs
- QueryException.cs
- ConnectionManager.cs
- MultipleCopiesCollection.cs
- Keywords.cs
- DataControlField.cs
- CreateRefExpr.cs
- XmlLangPropertyAttribute.cs
- DataGridTableCollection.cs
- DataSvcMapFile.cs
- QilTargetType.cs
- DataControlImageButton.cs
- DataTableClearEvent.cs
- UrlMappingsSection.cs
- ScrollData.cs
- ClonableStack.cs
- AxisAngleRotation3D.cs
- ExtendedTransformFactory.cs
- LinqTreeNodeEvaluator.cs
- SwitchAttribute.cs
- CqlBlock.cs
- OleStrCAMarshaler.cs
- ContextMenu.cs
- SqlTypesSchemaImporter.cs
- ScriptManagerProxy.cs
- prefixendpointaddressmessagefilter.cs
- HitTestResult.cs
- Point3D.cs
- LZCodec.cs
- Debugger.cs
- CorrelationRequestContext.cs
- ZipIOBlockManager.cs
- DirectionalLight.cs
- MetadataItemSerializer.cs
- ControlValuePropertyAttribute.cs
- PartitionerStatic.cs
- DataGridViewTextBoxEditingControl.cs
- RequiredArgumentAttribute.cs
- DefaultBindingPropertyAttribute.cs
- LoginDesigner.cs
- EntityDataSourceDesigner.cs
- MobileControlPersister.cs
- Crypto.cs
- RemoteWebConfigurationHostServer.cs
- PreProcessInputEventArgs.cs
- HtmlInputReset.cs
- baseaxisquery.cs