Code:
/ DotNET / DotNET / 8.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
- DbSourceCommand.cs
- RefreshEventArgs.cs
- XmlNamespaceManager.cs
- RsaSecurityToken.cs
- SubpageParaClient.cs
- Visual3D.cs
- DescendentsWalker.cs
- SerializationSectionGroup.cs
- CookielessData.cs
- ProgressBar.cs
- StringSorter.cs
- PointKeyFrameCollection.cs
- MaterialGroup.cs
- NativeMethods.cs
- XmlSchemaSimpleContentExtension.cs
- XmlDataLoader.cs
- ClientBuildManagerTypeDescriptionProviderBridge.cs
- CustomCredentialPolicy.cs
- SocketAddress.cs
- BaseTemplateBuildProvider.cs
- RegistrationServices.cs
- CatalogPart.cs
- UriExt.cs
- AttributedMetaModel.cs
- KeyTimeConverter.cs
- XmlEncodedRawTextWriter.cs
- ConfigurationValue.cs
- DataGridColumnCollection.cs
- BitmapEffect.cs
- ipaddressinformationcollection.cs
- HTMLTextWriter.cs
- BitmapEffectGroup.cs
- FamilyTypefaceCollection.cs
- MdiWindowListStrip.cs
- OpacityConverter.cs
- RuntimeConfigLKG.cs
- QilInvokeEarlyBound.cs
- CoTaskMemHandle.cs
- ResourceExpressionBuilder.cs
- TableCellsCollectionEditor.cs
- ByteStreamGeometryContext.cs
- WmlMobileTextWriter.cs
- ListSortDescription.cs
- Font.cs
- WebPartEditorOkVerb.cs
- _DisconnectOverlappedAsyncResult.cs
- _SslSessionsCache.cs
- XmlMapping.cs
- AddingNewEventArgs.cs
- CodeTypeReference.cs
- OdbcException.cs
- DataGridViewImageCell.cs
- FastEncoder.cs
- ExecutionEngineException.cs
- mediaeventargs.cs
- TrayIconDesigner.cs
- TrackingMemoryStreamFactory.cs
- CodeAccessPermission.cs
- XsltContext.cs
- StringCollectionMarkupSerializer.cs
- OleDbSchemaGuid.cs
- WebPartAddingEventArgs.cs
- Events.cs
- NonSerializedAttribute.cs
- EFAssociationProvider.cs
- StateManagedCollection.cs
- PersonalizablePropertyEntry.cs
- BinaryUtilClasses.cs
- AssemblyNameProxy.cs
- DataKeyCollection.cs
- ConnectivityStatus.cs
- Attribute.cs
- DataGridViewImageColumn.cs
- TransformPatternIdentifiers.cs
- ErrorsHelper.cs
- LocationSectionRecord.cs
- DelegateTypeInfo.cs
- EntityFunctions.cs
- PathFigureCollectionConverter.cs
- ComboBox.cs
- IgnoreSectionHandler.cs
- IListConverters.cs
- StringComparer.cs
- DictionaryContent.cs
- InvalidFilterCriteriaException.cs
- WebEventCodes.cs
- Decimal.cs
- DataIdProcessor.cs
- WindowsImpersonationContext.cs
- UnmanagedMemoryStreamWrapper.cs
- CodeDelegateCreateExpression.cs
- MobileErrorInfo.cs
- ExpressionEditorAttribute.cs
- EngineSiteSapi.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- TransformCollection.cs
- HierarchicalDataBoundControl.cs
- TreeViewDataItemAutomationPeer.cs
- EmptyElement.cs
- XmlSchemaAnyAttribute.cs