Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / CompMod / System / ComponentModel / CharConverter.cs / 1 / CharConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.ComponentModel { using Microsoft.Win32; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Runtime.Serialization.Formatters; using System.Runtime.Remoting; using System.Runtime.InteropServices; using System.Security.Permissions; ////// [HostProtection(SharedState = true)] public class CharConverter : TypeConverter { ///Provides /// a type converter to convert Unicode /// character objects to and from various other representations. ////// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } ///Gets a value indicating whether this converter can /// convert an object in the given source type to a Unicode character object using /// the specified context. ////// Converts the given object to another type. /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string) && value is char) { if ((char)value == (char)0) { return ""; } } return base.ConvertTo(context, culture, value, destinationType); } ////// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { string text = (string)value; if (text.Length > 1) { text = text.Trim(); } if (text != null && text.Length > 0) { if (text.Length != 1) { throw new FormatException(SR.GetString(SR.ConvertInvalidPrimitive, text, "Char")); } return text[0]; } return '\0'; } return base.ConvertFrom(context, culture, value); } } }Converts the given object to a Unicode character object. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StateRuntime.cs
- AggregateException.cs
- SqlDataSourceParameterParser.cs
- TokenDescriptor.cs
- FrameworkPropertyMetadata.cs
- EntityType.cs
- WindowsTokenRoleProvider.cs
- DependencyPropertyDescriptor.cs
- ListBindableAttribute.cs
- ScriptResourceAttribute.cs
- AssertValidation.cs
- HandlerFactoryWrapper.cs
- BmpBitmapDecoder.cs
- PeerContact.cs
- CodePrimitiveExpression.cs
- ConfigurationStrings.cs
- SingletonInstanceContextProvider.cs
- BitmapEffectGeneralTransform.cs
- OverrideMode.cs
- HandleExceptionArgs.cs
- DetailsViewCommandEventArgs.cs
- NamedPipeProcessProtocolHandler.cs
- CompilerResults.cs
- TableRow.cs
- TranslateTransform3D.cs
- XmlSchemaSimpleType.cs
- ValueSerializerAttribute.cs
- TemplateControlParser.cs
- ClipboardData.cs
- infer.cs
- Scripts.cs
- Symbol.cs
- VectorAnimationBase.cs
- XmlSchemaAll.cs
- ContainerAction.cs
- Substitution.cs
- HeaderCollection.cs
- Animatable.cs
- PerformanceCounter.cs
- WebUtil.cs
- QueryCursorEventArgs.cs
- MapPathBasedVirtualPathProvider.cs
- DocumentGridContextMenu.cs
- GcHandle.cs
- SqlAggregateChecker.cs
- CompilerHelpers.cs
- DictionaryEntry.cs
- WebServiceParameterData.cs
- ConfigXmlWhitespace.cs
- XmlSchemaAttributeGroupRef.cs
- HtmlControlPersistable.cs
- GroupByExpressionRewriter.cs
- IssuedTokensHeader.cs
- OdbcConnectionFactory.cs
- EnvironmentPermission.cs
- HttpCacheParams.cs
- CoreSwitches.cs
- MenuCommands.cs
- ZipIOExtraFieldPaddingElement.cs
- TextModifierScope.cs
- ClientBuildManagerCallback.cs
- ValueUtilsSmi.cs
- XPathNode.cs
- TimeSpanOrInfiniteValidator.cs
- BitmapEffectvisualstate.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- PropertyDescriptorGridEntry.cs
- WorkflowStateRollbackService.cs
- EntitySqlQueryCacheKey.cs
- RadioButton.cs
- CompModSwitches.cs
- Border.cs
- QilUnary.cs
- NamedElement.cs
- ActivityDesignerAccessibleObject.cs
- TextChangedEventArgs.cs
- OutputWindow.cs
- XmlMtomReader.cs
- BitmapEffectGroup.cs
- FileDialog_Vista.cs
- StrokeSerializer.cs
- StoragePropertyMapping.cs
- XhtmlBasicControlAdapter.cs
- MissingManifestResourceException.cs
- SourceChangedEventArgs.cs
- TypedTableBaseExtensions.cs
- FaultDescription.cs
- SmtpDigestAuthenticationModule.cs
- EntitySqlException.cs
- MaskedTextBox.cs
- cryptoapiTransform.cs
- EntitySqlQueryCacheKey.cs
- InvalidDataContractException.cs
- Attributes.cs
- FontWeightConverter.cs
- LicFileLicenseProvider.cs
- PerformanceCounter.cs
- PermissionSetTriple.cs
- SmiContextFactory.cs
- Point3DCollectionConverter.cs