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
- XmlILAnnotation.cs
- PropertyPath.cs
- WebPartEditVerb.cs
- SmtpFailedRecipientsException.cs
- ByteStreamGeometryContext.cs
- MenuItemStyleCollection.cs
- TemplateManager.cs
- Evaluator.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- AdjustableArrowCap.cs
- TriggerBase.cs
- InvalidPropValue.cs
- DataBindingHandlerAttribute.cs
- EndpointDispatcherTable.cs
- RadioButton.cs
- SchemaElementDecl.cs
- XamlHostingSection.cs
- DefaultPrintController.cs
- ipaddressinformationcollection.cs
- SelectorAutomationPeer.cs
- QilTargetType.cs
- BufferedReadStream.cs
- XmlUtf8RawTextWriter.cs
- infer.cs
- ReadOnlyCollectionBase.cs
- TextContainer.cs
- HMACSHA256.cs
- SafeFileMapViewHandle.cs
- ObjectSecurity.cs
- Label.cs
- ImageAnimator.cs
- HandlerFactoryCache.cs
- MessageQueueConverter.cs
- TextProperties.cs
- safelink.cs
- ParallelTimeline.cs
- HtmlTableRow.cs
- WebConfigurationManager.cs
- TaiwanCalendar.cs
- SqlClientMetaDataCollectionNames.cs
- ChannelCredentials.cs
- InternalBufferOverflowException.cs
- Span.cs
- GeometryDrawing.cs
- ToolStripPanelDesigner.cs
- StringSource.cs
- SspiNegotiationTokenAuthenticator.cs
- HttpVersion.cs
- WebBrowserSiteBase.cs
- CollectionBase.cs
- DropDownButton.cs
- Monitor.cs
- WebControl.cs
- Emitter.cs
- GridItemPattern.cs
- ReliabilityContractAttribute.cs
- ReadOnlyAttribute.cs
- PageEventArgs.cs
- TimelineCollection.cs
- QilChoice.cs
- BitStream.cs
- HostingPreferredMapPath.cs
- XmlSchemas.cs
- ProvideValueServiceProvider.cs
- Matrix3D.cs
- ScrollItemPattern.cs
- _CacheStreams.cs
- documentation.cs
- DataGridSortCommandEventArgs.cs
- CommandDevice.cs
- ResourceDescriptionAttribute.cs
- HttpContextWrapper.cs
- TextClipboardData.cs
- DiscreteKeyFrames.cs
- PenThread.cs
- BulletedListEventArgs.cs
- ChannelServices.cs
- AbsoluteQuery.cs
- BaseHashHelper.cs
- DeviceSpecificDesigner.cs
- Vector.cs
- StylusDownEventArgs.cs
- DbExpressionVisitor.cs
- ServiceBusyException.cs
- CodeAssignStatement.cs
- ListBindingConverter.cs
- wmiprovider.cs
- ButtonDesigner.cs
- OdbcEnvironment.cs
- ExpressionWriter.cs
- ElementProxy.cs
- ArcSegment.cs
- GlyphTypeface.cs
- LookupNode.cs
- DataIdProcessor.cs
- DataRecordObjectView.cs
- ProtectedProviderSettings.cs
- EventLog.cs
- OleServicesContext.cs
- BufferModesCollection.cs