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
- PermissionToken.cs
- Size3D.cs
- AdornerDecorator.cs
- HttpCachePolicyBase.cs
- LinqDataSourceInsertEventArgs.cs
- WrappedReader.cs
- WebDisplayNameAttribute.cs
- PointAnimation.cs
- MessageContractAttribute.cs
- GeometryDrawing.cs
- DBBindings.cs
- XPathBinder.cs
- Part.cs
- AmbiguousMatchException.cs
- unitconverter.cs
- AttributeParameterInfo.cs
- ImportDesigner.xaml.cs
- ImmComposition.cs
- ListItemCollection.cs
- SqlIdentifier.cs
- _PooledStream.cs
- HasCopySemanticsAttribute.cs
- COM2PropertyBuilderUITypeEditor.cs
- FontCollection.cs
- NullableBoolConverter.cs
- AuthenticationModulesSection.cs
- Rotation3DAnimationBase.cs
- ObjectPersistData.cs
- ListParagraph.cs
- List.cs
- RectKeyFrameCollection.cs
- DataGridViewCellValidatingEventArgs.cs
- DecoderReplacementFallback.cs
- RichTextBoxAutomationPeer.cs
- GradientStopCollection.cs
- CodeThrowExceptionStatement.cs
- PriorityBinding.cs
- IERequestCache.cs
- StringUtil.cs
- WebHeaderCollection.cs
- IisTraceListener.cs
- ExtendedProtectionPolicyTypeConverter.cs
- SizeLimitedCache.cs
- WaitHandleCannotBeOpenedException.cs
- TriggerActionCollection.cs
- assertwrapper.cs
- ModelTreeEnumerator.cs
- SqlParameter.cs
- SocketElement.cs
- Geometry3D.cs
- SortedDictionary.cs
- ExpressionDumper.cs
- ReadOnlyHierarchicalDataSourceView.cs
- StickyNoteAnnotations.cs
- RawMouseInputReport.cs
- WinFormsUtils.cs
- contentDescriptor.cs
- XmlLinkedNode.cs
- __Filters.cs
- StylusButtonEventArgs.cs
- GenericWebPart.cs
- ContainerVisual.cs
- DiagnosticsConfigurationHandler.cs
- KeyProperty.cs
- VolatileEnlistmentMultiplexing.cs
- ChildDocumentBlock.cs
- AttributedMetaModel.cs
- XmlQueryCardinality.cs
- X509CertificateRecipientServiceCredential.cs
- Task.cs
- ToolTipService.cs
- ConfigurationPropertyCollection.cs
- WasEndpointConfigContainer.cs
- RenameRuleObjectDialog.Designer.cs
- HttpModuleActionCollection.cs
- ReachPrintTicketSerializer.cs
- TypeInfo.cs
- GridLengthConverter.cs
- LinqDataSourceHelper.cs
- ListViewAutomationPeer.cs
- CompilerGlobalScopeAttribute.cs
- AsyncResult.cs
- DateTime.cs
- SqlPersonalizationProvider.cs
- DictionarySurrogate.cs
- StrongTypingException.cs
- SpecialFolderEnumConverter.cs
- SecurityContextSecurityTokenResolver.cs
- ComPlusInstanceContextInitializer.cs
- DbMetaDataCollectionNames.cs
- SafeCertificateContext.cs
- BaseAsyncResult.cs
- InternalCache.cs
- XmlAttribute.cs
- ResolveMatchesMessage11.cs
- FlowDocument.cs
- MultilineStringConverter.cs
- _SslStream.cs
- DbConnectionPoolCounters.cs
- FutureFactory.cs