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
- FlatButtonAppearance.cs
- namescope.cs
- RepeaterItem.cs
- HybridDictionary.cs
- SupportingTokenDuplexChannel.cs
- RtfToXamlReader.cs
- CommandHelpers.cs
- TempFiles.cs
- StatusBarAutomationPeer.cs
- ItemAutomationPeer.cs
- WindowClosedEventArgs.cs
- CompilerError.cs
- _FixedSizeReader.cs
- M3DUtil.cs
- FormViewCommandEventArgs.cs
- XmlILCommand.cs
- PanelDesigner.cs
- _SpnDictionary.cs
- HtmlToClrEventProxy.cs
- RegexWorker.cs
- VerificationException.cs
- serverconfig.cs
- DeclaredTypeValidator.cs
- Rect3D.cs
- DrawingAttributes.cs
- COM2ColorConverter.cs
- OutputCacheProfile.cs
- Popup.cs
- ExecutionTracker.cs
- LogSwitch.cs
- NotFiniteNumberException.cs
- DataGridViewCellStyleConverter.cs
- MembershipValidatePasswordEventArgs.cs
- FirewallWrapper.cs
- RSAOAEPKeyExchangeDeformatter.cs
- StyleCollection.cs
- SByte.cs
- OdbcPermission.cs
- CodeFieldReferenceExpression.cs
- BindToObject.cs
- Selector.cs
- ManagementException.cs
- LineSegment.cs
- WebPartMenu.cs
- UrlPath.cs
- BuildProviderCollection.cs
- SQLDouble.cs
- SiteMap.cs
- NavigationExpr.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- DecimalConstantAttribute.cs
- InvokePatternIdentifiers.cs
- TdsEnums.cs
- LoginName.cs
- SQLInt32.cs
- BitmapDecoder.cs
- TransformerConfigurationWizardBase.cs
- BooleanFunctions.cs
- SaveFileDialogDesigner.cs
- TaskCanceledException.cs
- ResizingMessageFilter.cs
- CompositeControl.cs
- HttpClientCertificate.cs
- OptimizedTemplateContent.cs
- CodeCommentStatement.cs
- ThemeInfoAttribute.cs
- CompareInfo.cs
- LeaseManager.cs
- SqlDataAdapter.cs
- Int64Storage.cs
- EntryIndex.cs
- DoubleLink.cs
- DocComment.cs
- Simplifier.cs
- FixedSOMImage.cs
- UnknownWrapper.cs
- RSAProtectedConfigurationProvider.cs
- ProfessionalColors.cs
- SerializerWriterEventHandlers.cs
- EndpointAddressProcessor.cs
- WindowClosedEventArgs.cs
- TableRow.cs
- PrefixHandle.cs
- DetailsViewUpdatedEventArgs.cs
- ConnectionManagementSection.cs
- Crc32.cs
- TypefaceMap.cs
- NonceToken.cs
- UrlMapping.cs
- DataViewManager.cs
- SevenBitStream.cs
- RoleService.cs
- NeutralResourcesLanguageAttribute.cs
- RelationshipManager.cs
- SortAction.cs
- SeekStoryboard.cs
- OdbcErrorCollection.cs
- DodSequenceMerge.cs
- FrameworkContentElement.cs
- HostVisual.cs