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
- LockRecursionException.cs
- PrintPreviewGraphics.cs
- StyleTypedPropertyAttribute.cs
- RuntimeWrappedException.cs
- CompensationExtension.cs
- OdbcConnectionStringbuilder.cs
- KeyTime.cs
- CompositeCollection.cs
- SamlEvidence.cs
- ResourceContainer.cs
- MessageSecurityVersion.cs
- ObjectListComponentEditor.cs
- _SafeNetHandles.cs
- MenuAutomationPeer.cs
- DelegatedStream.cs
- SslStream.cs
- WebPartZone.cs
- NameValueCache.cs
- SmtpNtlmAuthenticationModule.cs
- Win32.cs
- DictionaryItemsCollection.cs
- CompilerTypeWithParams.cs
- XmlSerializer.cs
- DataGridViewCellConverter.cs
- ActivityInfo.cs
- MethodBuilder.cs
- BookmarkScope.cs
- ListViewItemSelectionChangedEvent.cs
- DataGridViewImageColumn.cs
- AssemblyAttributes.cs
- ImageClickEventArgs.cs
- RetrieveVirtualItemEventArgs.cs
- XmlNodeComparer.cs
- FontDriver.cs
- EncoderNLS.cs
- Byte.cs
- Pair.cs
- WebPartDisplayMode.cs
- PixelFormatConverter.cs
- Stylesheet.cs
- SchemaTableOptionalColumn.cs
- HasCopySemanticsAttribute.cs
- RowsCopiedEventArgs.cs
- AttributeEmitter.cs
- QueryTask.cs
- CancelRequestedQuery.cs
- HttpResponseHeader.cs
- XmlTypeMapping.cs
- SerializerWriterEventHandlers.cs
- LockCookie.cs
- ButtonChrome.cs
- WebSysDisplayNameAttribute.cs
- CheckBox.cs
- XmlWellformedWriter.cs
- StorageSetMapping.cs
- DataObjectMethodAttribute.cs
- Socket.cs
- URLEditor.cs
- CharEntityEncoderFallback.cs
- FileDialogCustomPlaces.cs
- DotExpr.cs
- SafeFileMappingHandle.cs
- ResourceWriter.cs
- BitmapEffect.cs
- SafeCertificateContext.cs
- _LoggingObject.cs
- TextElementEnumerator.cs
- DesignTimeValidationFeature.cs
- TreeViewImageIndexConverter.cs
- WeakHashtable.cs
- FixedFlowMap.cs
- MaterialCollection.cs
- MsmqMessageSerializationFormat.cs
- XmlSchemaProviderAttribute.cs
- ConfigurationManagerInternalFactory.cs
- StringDictionaryCodeDomSerializer.cs
- Help.cs
- SchemaTableOptionalColumn.cs
- JsonServiceDocumentSerializer.cs
- WorkerRequest.cs
- SqlExpressionNullability.cs
- CodeCompiler.cs
- PathNode.cs
- SessionSwitchEventArgs.cs
- InkCanvasFeedbackAdorner.cs
- Blend.cs
- TouchesOverProperty.cs
- FormatterConverter.cs
- ConfigurationHelpers.cs
- XPathAncestorQuery.cs
- MetadataCache.cs
- PerformanceCountersElement.cs
- SmtpNegotiateAuthenticationModule.cs
- IdleTimeoutMonitor.cs
- Scene3D.cs
- PositiveTimeSpanValidatorAttribute.cs
- FrameworkTextComposition.cs
- ApplicationContext.cs
- Icon.cs
- DecimalAnimationBase.cs