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
- AutoGeneratedFieldProperties.cs
- HtmlTable.cs
- TemplateAction.cs
- AutoCompleteStringCollection.cs
- PingReply.cs
- WebControlsSection.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- DataSpaceManager.cs
- SingleAnimation.cs
- ComplexBindingPropertiesAttribute.cs
- Operand.cs
- SQLMoneyStorage.cs
- Mutex.cs
- FaultDesigner.cs
- SessionState.cs
- LineBreakRecord.cs
- BoolExpression.cs
- AsyncPostBackTrigger.cs
- EnvelopedPkcs7.cs
- EventOpcode.cs
- IntSecurity.cs
- WorkflowMarkupSerializer.cs
- HostUtils.cs
- BuildProvidersCompiler.cs
- Vector3DAnimationBase.cs
- SelectionItemProviderWrapper.cs
- StorageFunctionMapping.cs
- TempEnvironment.cs
- TextDocumentView.cs
- SingleTagSectionHandler.cs
- PowerStatus.cs
- DefaultShape.cs
- CompressedStack.cs
- NonVisualControlAttribute.cs
- DataBindingCollection.cs
- KeyNotFoundException.cs
- GiveFeedbackEvent.cs
- ToolStripStatusLabel.cs
- GeometryModel3D.cs
- ValidationRuleCollection.cs
- TlsnegoTokenProvider.cs
- QueryConverter.cs
- VirtualizingStackPanel.cs
- SuppressMergeCheckAttribute.cs
- FieldAccessException.cs
- LinqExpressionNormalizer.cs
- DataRelationPropertyDescriptor.cs
- SessionParameter.cs
- ObjectStorage.cs
- PackageFilter.cs
- ApplicationServiceHelper.cs
- MutexSecurity.cs
- ReadOnlyTernaryTree.cs
- TypeUnloadedException.cs
- ThemeInfoAttribute.cs
- WebConvert.cs
- StringUtil.cs
- BigInt.cs
- ToolboxItemAttribute.cs
- DescendentsWalker.cs
- sqlnorm.cs
- CodePropertyReferenceExpression.cs
- FilteredDataSetHelper.cs
- StaticExtensionConverter.cs
- Mouse.cs
- ResourceProperty.cs
- WorkerRequest.cs
- SectionVisual.cs
- EventSinkHelperWriter.cs
- SafeProcessHandle.cs
- MemoryFailPoint.cs
- Point3DKeyFrameCollection.cs
- LocalizeDesigner.cs
- SafeFileMappingHandle.cs
- TerminateDesigner.cs
- ListViewItemSelectionChangedEvent.cs
- XamlReader.cs
- TextEncodedRawTextWriter.cs
- NameValueSectionHandler.cs
- OperationInvokerTrace.cs
- VerticalAlignConverter.cs
- ClassDataContract.cs
- GenerateDerivedKeyRequest.cs
- DoubleLink.cs
- XmlDesigner.cs
- HTTPAPI_VERSION.cs
- ButtonBase.cs
- SelectorAutomationPeer.cs
- GroupBoxRenderer.cs
- DbException.cs
- XmlSerializerNamespaces.cs
- BitmapEffectDrawingContextWalker.cs
- ServiceDurableInstanceContextProvider.cs
- FontSourceCollection.cs
- SizeFConverter.cs
- Parameter.cs
- XPathMessageFilterElementCollection.cs
- httpapplicationstate.cs
- Debug.cs
- Array.cs