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
- Timeline.cs
- ParseNumbers.cs
- FontFamilyValueSerializer.cs
- SortQuery.cs
- IERequestCache.cs
- DbConnectionStringBuilder.cs
- ListChangedEventArgs.cs
- CreatingCookieEventArgs.cs
- RenderData.cs
- CompilerGeneratedAttribute.cs
- VirtualizingStackPanel.cs
- HandlerBase.cs
- Debug.cs
- CompoundFileDeflateTransform.cs
- StorageFunctionMapping.cs
- DataGridViewRow.cs
- EntityModelBuildProvider.cs
- MetadataItem.cs
- ContentFilePart.cs
- TemplateKey.cs
- GradientStop.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- ImageCodecInfo.cs
- BulletChrome.cs
- CollectionsUtil.cs
- httpstaticobjectscollection.cs
- DataRow.cs
- UserControlCodeDomTreeGenerator.cs
- SiblingIterators.cs
- DSACryptoServiceProvider.cs
- PageWrapper.cs
- HttpCacheVaryByContentEncodings.cs
- PropertyEmitter.cs
- WindowsRichEdit.cs
- MenuEventArgs.cs
- FormCollection.cs
- GetReadStreamResult.cs
- ReflectEventDescriptor.cs
- KnownTypesHelper.cs
- CoTaskMemHandle.cs
- XMLSyntaxException.cs
- ActivityDesigner.cs
- GlyphElement.cs
- SqlPersistenceWorkflowInstanceDescription.cs
- MobileListItem.cs
- DisposableCollectionWrapper.cs
- CodeMethodReturnStatement.cs
- XmlReturnReader.cs
- DesignerDataStoredProcedure.cs
- Normalization.cs
- COM2Properties.cs
- SpinLock.cs
- DataTableMappingCollection.cs
- ListViewInsertionMark.cs
- XmlReflectionImporter.cs
- Renderer.cs
- RemoteWebConfigurationHost.cs
- PasswordRecovery.cs
- SymbolTable.cs
- ToolStripSeparatorRenderEventArgs.cs
- WebPartMinimizeVerb.cs
- OracleParameter.cs
- TimeZoneInfo.cs
- TrackingStringDictionary.cs
- AttributeSetAction.cs
- Empty.cs
- ToolStripOverflowButton.cs
- DBConcurrencyException.cs
- WriterOutput.cs
- Stacktrace.cs
- IOException.cs
- ContextStaticAttribute.cs
- XmlCDATASection.cs
- RankException.cs
- HttpCapabilitiesBase.cs
- X509ChainElement.cs
- Guid.cs
- TrackingMemoryStreamFactory.cs
- Solver.cs
- ColumnHeader.cs
- Calendar.cs
- NetworkCredential.cs
- WasHttpHandlersInstallComponent.cs
- BooleanConverter.cs
- DataGridViewComboBoxColumn.cs
- NameValueConfigurationElement.cs
- KeyToListMap.cs
- TracePayload.cs
- ClientTargetCollection.cs
- PropertyBuilder.cs
- TemplateInstanceAttribute.cs
- ItemCheckEvent.cs
- InkCanvasAutomationPeer.cs
- AttributeProviderAttribute.cs
- ColumnClickEvent.cs
- QilXmlReader.cs
- ProcessingInstructionAction.cs
- IdnMapping.cs
- LogicalExpr.cs
- SQLInt16Storage.cs