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
- CompoundFileDeflateTransform.cs
- DecoderExceptionFallback.cs
- HyperlinkAutomationPeer.cs
- EncodingNLS.cs
- FixedSOMContainer.cs
- ReliableRequestSessionChannel.cs
- WindowsListView.cs
- WindowsStartMenu.cs
- IdentityNotMappedException.cs
- XmlAttributeAttribute.cs
- RuntimeHandles.cs
- NavigationService.cs
- ErrorWebPart.cs
- MessageDispatch.cs
- TextStore.cs
- ProxyWebPartManagerDesigner.cs
- PackageDigitalSignature.cs
- Point3DAnimationBase.cs
- AttributeQuery.cs
- WSFederationHttpBindingElement.cs
- TransformerInfoCollection.cs
- ReflectPropertyDescriptor.cs
- BindingNavigatorDesigner.cs
- TypeInitializationException.cs
- PerformanceCounterPermission.cs
- EntityParameter.cs
- DataTableCollection.cs
- HorizontalAlignConverter.cs
- UriExt.cs
- Helpers.cs
- Int32Converter.cs
- PerformanceCountersElement.cs
- EntityFunctions.cs
- InteropBitmapSource.cs
- WebPartCatalogAddVerb.cs
- XsltQilFactory.cs
- TabItemAutomationPeer.cs
- ServiceRouteHandler.cs
- DataTemplate.cs
- ListDictionaryInternal.cs
- BindingOperations.cs
- IgnoreFileBuildProvider.cs
- DataKeyCollection.cs
- StateMachineWorkflowInstance.cs
- SemanticTag.cs
- ProfileSection.cs
- UInt16Converter.cs
- ConfigurationManagerHelper.cs
- PropertyIDSet.cs
- SafeArrayRankMismatchException.cs
- Visitor.cs
- SecurityDocument.cs
- PageSettings.cs
- AssemblyInfo.cs
- StringUtil.cs
- UniqueIdentifierService.cs
- MdiWindowListStrip.cs
- ReaderWriterLock.cs
- SessionStateSection.cs
- MetadataItemEmitter.cs
- UiaCoreApi.cs
- RequestSecurityTokenResponse.cs
- OLEDB_Enum.cs
- WeakReadOnlyCollection.cs
- XmlSchemaComplexContent.cs
- CharacterMetrics.cs
- GridView.cs
- LoadRetryAsyncResult.cs
- DataServiceException.cs
- EmbeddedObject.cs
- MatchAttribute.cs
- XmlTextEncoder.cs
- GlobalAllocSafeHandle.cs
- FileIOPermission.cs
- AutomationPropertyInfo.cs
- SafeCryptHandles.cs
- BitConverter.cs
- ListView.cs
- FilterQueryOptionExpression.cs
- ConfigurationSettings.cs
- ComPlusTypeLoader.cs
- Rotation3DAnimationBase.cs
- TextParagraph.cs
- GatewayDefinition.cs
- OdbcCommand.cs
- RowToFieldTransformer.cs
- ReadOnlyDataSourceView.cs
- TransformDescriptor.cs
- VisualStateGroup.cs
- _KerberosClient.cs
- Hyperlink.cs
- DeviceContext2.cs
- StrokeSerializer.cs
- CultureTable.cs
- AnnotationObservableCollection.cs
- ParameterCollection.cs
- XmlParserContext.cs
- SignedXml.cs
- WeakReferenceList.cs
- LongValidator.cs