Code:
/ DotNET / DotNET / 8.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
- TypeBuilderInstantiation.cs
- URLMembershipCondition.cs
- HttpSessionStateBase.cs
- HeaderPanel.cs
- UriTemplateTable.cs
- WebBrowsableAttribute.cs
- ConsoleKeyInfo.cs
- DifferencingCollection.cs
- MailWebEventProvider.cs
- GenericParameterDataContract.cs
- XmlCustomFormatter.cs
- RtfFormatStack.cs
- DataListItemEventArgs.cs
- ConfigurationManagerInternalFactory.cs
- COMException.cs
- SafeEventLogWriteHandle.cs
- TypeDescriptorContext.cs
- InputScopeAttribute.cs
- XmlEncoding.cs
- WebRequestModulesSection.cs
- WS2007HttpBinding.cs
- ChangeNode.cs
- KnownBoxes.cs
- Triplet.cs
- Missing.cs
- ScriptManager.cs
- Assert.cs
- ManagementOperationWatcher.cs
- ForEachAction.cs
- XMLSyntaxException.cs
- ipaddressinformationcollection.cs
- PolyBezierSegment.cs
- ScaleTransform3D.cs
- AudioFormatConverter.cs
- MessageQueueException.cs
- FormatException.cs
- FragmentNavigationEventArgs.cs
- VisualTreeHelper.cs
- CodeTypeDelegate.cs
- MessageQueueException.cs
- PhysicalOps.cs
- TextEffectResolver.cs
- DirectionalLight.cs
- ConstNode.cs
- CompleteWizardStep.cs
- QuestionEventArgs.cs
- BStrWrapper.cs
- FixedTextView.cs
- QueryInterceptorAttribute.cs
- SharedPersonalizationStateInfo.cs
- PathParser.cs
- MessageSecurityVersion.cs
- UserControlBuildProvider.cs
- TextElementCollection.cs
- XmlDocumentType.cs
- Transform3D.cs
- SoapHttpTransportImporter.cs
- Int64AnimationUsingKeyFrames.cs
- FormViewInsertEventArgs.cs
- TemplateXamlParser.cs
- CodeComment.cs
- SiteMapHierarchicalDataSourceView.cs
- HttpFileCollection.cs
- DatePicker.cs
- NavigationProperty.cs
- Int32Storage.cs
- elementinformation.cs
- Icon.cs
- HtmlEncodedRawTextWriter.cs
- PlanCompilerUtil.cs
- TypeLibConverter.cs
- Identifier.cs
- FileFormatException.cs
- SplitterPanel.cs
- ToolStripDropDownButton.cs
- WmlTextViewAdapter.cs
- CreatingCookieEventArgs.cs
- DaylightTime.cs
- HTMLTextWriter.cs
- DataColumnCollection.cs
- ScriptManager.cs
- PropertyBuilder.cs
- BorderGapMaskConverter.cs
- SafeSecurityHandles.cs
- FileIOPermission.cs
- COMException.cs
- WindowsIdentity.cs
- HttpWriter.cs
- TransactionValidationBehavior.cs
- PerformanceCounterLib.cs
- CriticalHandle.cs
- DynamicActivityProperty.cs
- InfoCardSymmetricCrypto.cs
- DataGridViewCellPaintingEventArgs.cs
- FeatureSupport.cs
- Int64Animation.cs
- BinaryObjectWriter.cs
- ControlCollection.cs
- EnumConverter.cs
- ContentDefinition.cs