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
- SiteMapNodeItem.cs
- EdmItemCollection.OcAssemblyCache.cs
- HttpDebugHandler.cs
- SynchronousSendBindingElement.cs
- ModifiableIteratorCollection.cs
- SqlEnums.cs
- IdentityReference.cs
- StructuralType.cs
- ProgressBar.cs
- UnionQueryOperator.cs
- Utilities.cs
- CompositeFontParser.cs
- MainMenu.cs
- StringReader.cs
- FormatPage.cs
- XmlSignificantWhitespace.cs
- XamlDebuggerXmlReader.cs
- CheckBoxAutomationPeer.cs
- Column.cs
- cookiecollection.cs
- PrtCap_Base.cs
- TreeNode.cs
- BooleanToVisibilityConverter.cs
- shaperfactory.cs
- WindowsRebar.cs
- MaterialGroup.cs
- IDReferencePropertyAttribute.cs
- ConfigurationStrings.cs
- TreeWalkHelper.cs
- LocalsItemDescription.cs
- Util.cs
- TextRunCacheImp.cs
- TogglePatternIdentifiers.cs
- SelectionEditingBehavior.cs
- ControlTemplate.cs
- TemplateModeChangedEventArgs.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ValidatedControlConverter.cs
- KnownIds.cs
- DynamicDataRoute.cs
- DesignerView.cs
- SafeCryptoHandles.cs
- HttpWebRequest.cs
- Crypto.cs
- DrawingAttributesDefaultValueFactory.cs
- MappingException.cs
- Sql8ExpressionRewriter.cs
- PropertyMetadata.cs
- Domain.cs
- XmlDataProvider.cs
- X509ChainElement.cs
- PackWebRequestFactory.cs
- StyleCollection.cs
- GenericNameHandler.cs
- BlobPersonalizationState.cs
- KnownTypesProvider.cs
- XmlSchemaDatatype.cs
- ObjectCloneHelper.cs
- ProcessInfo.cs
- MembershipAdapter.cs
- OracleBFile.cs
- StringUtil.cs
- FileVersion.cs
- CompositeFontInfo.cs
- IResourceProvider.cs
- Solver.cs
- SqlNode.cs
- XmlSiteMapProvider.cs
- FrugalList.cs
- StorageScalarPropertyMapping.cs
- HasCopySemanticsAttribute.cs
- MergeFailedEvent.cs
- DateTimeConverter2.cs
- XmlNodeReader.cs
- documentsequencetextpointer.cs
- StringSource.cs
- GroupDescription.cs
- Version.cs
- NestPullup.cs
- CommandCollectionEditor.cs
- Misc.cs
- DefaultTextStore.cs
- VisualTransition.cs
- AppDomainShutdownMonitor.cs
- TrustLevel.cs
- BasicExpandProvider.cs
- MessageBuffer.cs
- BrowserInteropHelper.cs
- SecurityPolicySection.cs
- SecurityUtils.cs
- ExtractCollection.cs
- XmlNamespaceManager.cs
- HeaderCollection.cs
- ComponentSerializationService.cs
- Rect3DValueSerializer.cs
- EntityObject.cs
- ObjectListTitleAttribute.cs
- ToolboxComponentsCreatedEventArgs.cs
- objectquery_tresulttype.cs
- TreeViewItem.cs