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
- TextEndOfSegment.cs
- Number.cs
- filewebresponse.cs
- XmlUtil.cs
- Normalization.cs
- DragAssistanceManager.cs
- PartialArray.cs
- ProfilePropertySettings.cs
- ControlIdConverter.cs
- ValidationError.cs
- ManualResetEvent.cs
- SafeFileMappingHandle.cs
- Imaging.cs
- FixedTextBuilder.cs
- Converter.cs
- XmlDocumentType.cs
- XmlILOptimizerVisitor.cs
- ToolboxDataAttribute.cs
- MatrixAnimationUsingPath.cs
- TreeSet.cs
- DecoderBestFitFallback.cs
- CodeStatement.cs
- CapabilitiesState.cs
- MaskedTextBoxTextEditor.cs
- RootBuilder.cs
- PropertyGridCommands.cs
- EventLogPermissionAttribute.cs
- InternalResources.cs
- RelationshipDetailsCollection.cs
- GridViewItemAutomationPeer.cs
- StylusPoint.cs
- BitmapEffectState.cs
- RuleSettingsCollection.cs
- SqlInternalConnectionSmi.cs
- EventEntry.cs
- TrackingCondition.cs
- MimeFormatter.cs
- BitmapMetadata.cs
- GridViewCommandEventArgs.cs
- Validator.cs
- DeferrableContent.cs
- SortKey.cs
- SettingsBindableAttribute.cs
- XmlTextReaderImpl.cs
- X509CertificateCollection.cs
- SslStreamSecurityElement.cs
- ConfigXmlCDataSection.cs
- AssemblySettingAttributes.cs
- StaticContext.cs
- ReadWriteControlDesigner.cs
- EndpointConfigContainer.cs
- Decoder.cs
- SynchronizationFilter.cs
- DbDataSourceEnumerator.cs
- HtmlDocument.cs
- XmlUTF8TextWriter.cs
- ApplyTemplatesAction.cs
- ObjectConverter.cs
- XmlQueryType.cs
- SchemaConstraints.cs
- SinglePhaseEnlistment.cs
- ClientTargetSection.cs
- XmlProcessingInstruction.cs
- TextEncodedRawTextWriter.cs
- NextPreviousPagerField.cs
- ConfigUtil.cs
- XmlProcessingInstruction.cs
- figurelengthconverter.cs
- EditorPart.cs
- FileReservationCollection.cs
- XpsS0ValidatingLoader.cs
- ActiveDocumentEvent.cs
- VerticalAlignConverter.cs
- DataGridViewControlCollection.cs
- Interlocked.cs
- handlecollector.cs
- CharacterBufferReference.cs
- QuaternionAnimation.cs
- ImageMapEventArgs.cs
- TypeDependencyAttribute.cs
- mactripleDES.cs
- UnsafeNativeMethodsMilCoreApi.cs
- ZoomPercentageConverter.cs
- ProjectionPathBuilder.cs
- XmlTypeMapping.cs
- XmlSchemaSimpleContent.cs
- EventData.cs
- DBSchemaTable.cs
- CustomError.cs
- Constants.cs
- XsdBuildProvider.cs
- ConfigXmlSignificantWhitespace.cs
- CompilationUnit.cs
- SessionStateItemCollection.cs
- StretchValidation.cs
- MetadataWorkspace.cs
- StateRuntime.cs
- Type.cs
- TemplatePropertyEntry.cs
- FrameworkEventSource.cs