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
- ToolStripOverflow.cs
- ExtenderProvidedPropertyAttribute.cs
- Permission.cs
- FreezableOperations.cs
- PropertyChangedEventArgs.cs
- BitmapCodecInfo.cs
- ViewCellRelation.cs
- log.cs
- XmlSerializerAssemblyAttribute.cs
- Margins.cs
- RoleServiceManager.cs
- XmlEntity.cs
- Dump.cs
- GridViewSortEventArgs.cs
- ImportCatalogPart.cs
- Accessors.cs
- WebPartPersonalization.cs
- ConfigLoader.cs
- storagemappingitemcollection.viewdictionary.cs
- HtmlHead.cs
- NavigatorInput.cs
- IChannel.cs
- HitTestParameters3D.cs
- ClientTargetCollection.cs
- UniqueCodeIdentifierScope.cs
- ExpressionBuilderCollection.cs
- Guid.cs
- DWriteFactory.cs
- TextDecorations.cs
- HttpModule.cs
- BitConverter.cs
- ModuleBuilderData.cs
- HttpServerUtilityBase.cs
- ViewBase.cs
- MexHttpsBindingElement.cs
- XPathAxisIterator.cs
- lengthconverter.cs
- TrailingSpaceComparer.cs
- TableHeaderCell.cs
- MimeParameter.cs
- UserNameSecurityToken.cs
- AlphaSortedEnumConverter.cs
- ColorBlend.cs
- LineServices.cs
- MimeMapping.cs
- KeyedHashAlgorithm.cs
- TextTreeUndoUnit.cs
- DefaultTextStore.cs
- GridViewDeletedEventArgs.cs
- FixedPageStructure.cs
- EnumType.cs
- ScrollEventArgs.cs
- Splitter.cs
- MenuItemCollectionEditorDialog.cs
- ColorAnimation.cs
- HTMLTextWriter.cs
- StringUtil.cs
- SoapClientMessage.cs
- OuterGlowBitmapEffect.cs
- ScriptModule.cs
- ProxyAttribute.cs
- FormParameter.cs
- AsymmetricKeyExchangeDeformatter.cs
- MissingManifestResourceException.cs
- ToolBarTray.cs
- WindowsListViewItem.cs
- TdsParameterSetter.cs
- GeometryConverter.cs
- RetrieveVirtualItemEventArgs.cs
- MsmqOutputChannel.cs
- QuaternionValueSerializer.cs
- KeyboardDevice.cs
- OutputCacheModule.cs
- DataAdapter.cs
- SystemWebCachingSectionGroup.cs
- NumericUpDown.cs
- XslTransform.cs
- IItemProperties.cs
- StyleCollection.cs
- SystemWebCachingSectionGroup.cs
- JapaneseCalendar.cs
- ColorMap.cs
- XmlUTF8TextWriter.cs
- httpstaticobjectscollection.cs
- ContainerParagraph.cs
- CallContext.cs
- ObjectPersistData.cs
- ToolStripItemRenderEventArgs.cs
- ConfigXmlCDataSection.cs
- CellIdBoolean.cs
- Stroke.cs
- Msec.cs
- GridItemCollection.cs
- BasicExpandProvider.cs
- MissingMemberException.cs
- ConfigurationPropertyCollection.cs
- WmpBitmapDecoder.cs
- ContextStack.cs
- ObjectItemCollection.cs
- TextDecorationCollectionConverter.cs