Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / ComponentModel / CharConverter.cs / 1305376 / 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.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
- ItemsPresenter.cs
- VolatileEnlistmentMultiplexing.cs
- followingsibling.cs
- DBDataPermission.cs
- TextSpanModifier.cs
- DiagnosticsConfigurationHandler.cs
- SafeFileHandle.cs
- TextDecorationLocationValidation.cs
- CompareValidator.cs
- SmiRequestExecutor.cs
- RawKeyboardInputReport.cs
- Binding.cs
- ParserContext.cs
- FixedSOMElement.cs
- ResourceManager.cs
- ProfileSection.cs
- CustomPeerResolverService.cs
- SocketException.cs
- XmlUtil.cs
- DataGridViewCellValidatingEventArgs.cs
- MemberNameValidator.cs
- OrCondition.cs
- HttpInputStream.cs
- BinaryObjectReader.cs
- AccessKeyManager.cs
- CompModHelpers.cs
- XmlSchemaImporter.cs
- MenuItemBinding.cs
- SelectionManager.cs
- FontConverter.cs
- recordstatescratchpad.cs
- SequenceFullException.cs
- RangeExpression.cs
- HttpHandlersSection.cs
- SoapIncludeAttribute.cs
- HelpHtmlBuilder.cs
- HttpHeaderCollection.cs
- TextOptions.cs
- FreezableDefaultValueFactory.cs
- DataGridCommandEventArgs.cs
- RoutedUICommand.cs
- BinaryFormatterWriter.cs
- BrushConverter.cs
- StorageEntityTypeMapping.cs
- CollectionsUtil.cs
- XmlArrayAttribute.cs
- FormatterServices.cs
- DataGridViewRowsAddedEventArgs.cs
- TextFormatter.cs
- XmlWrappingReader.cs
- MasterPageCodeDomTreeGenerator.cs
- PageCatalogPart.cs
- BamlVersionHeader.cs
- TextBoxAutomationPeer.cs
- BuiltInExpr.cs
- JoinCqlBlock.cs
- XmlNamespaceMapping.cs
- PolicyChain.cs
- storepermission.cs
- SimpleModelProvider.cs
- TextLineBreak.cs
- CustomAttributeBuilder.cs
- ConfigurationException.cs
- XmlNavigatorFilter.cs
- GridItemPattern.cs
- TrackingMemoryStream.cs
- BezierSegment.cs
- TagMapCollection.cs
- AutoResetEvent.cs
- DataGridrowEditEndingEventArgs.cs
- Rotation3DAnimation.cs
- ProfileSection.cs
- KeyInfo.cs
- TimerElapsedEvenArgs.cs
- InputLanguageEventArgs.cs
- TransactionProtocolConverter.cs
- MSAANativeProvider.cs
- BinaryMethodMessage.cs
- DisplayMemberTemplateSelector.cs
- SqlTransaction.cs
- SizeIndependentAnimationStorage.cs
- oledbconnectionstring.cs
- DataSourceCacheDurationConverter.cs
- ScriptResourceAttribute.cs
- MultiDataTrigger.cs
- WebPartDescription.cs
- WebPartCatalogAddVerb.cs
- LoginCancelEventArgs.cs
- GcSettings.cs
- DeobfuscatingStream.cs
- MediaCommands.cs
- AppliedDeviceFiltersEditor.cs
- CategoryAttribute.cs
- MetadataReference.cs
- ApplicationDirectory.cs
- ColorEditor.cs
- GestureRecognizer.cs
- ValidatingCollection.cs
- WebPartAuthorizationEventArgs.cs
- ButtonChrome.cs