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
- LinqDataSourceContextEventArgs.cs
- lengthconverter.cs
- DecimalKeyFrameCollection.cs
- ProfileProvider.cs
- MetabaseServerConfig.cs
- DesignerAttribute.cs
- ComponentEditorForm.cs
- EntityDataSourceWrapperCollection.cs
- XmlSchemaAttributeGroupRef.cs
- NameValuePair.cs
- RC2CryptoServiceProvider.cs
- XmlWrappingReader.cs
- XmlQualifiedName.cs
- BatchParser.cs
- DbParameterCollectionHelper.cs
- RemotingConfigParser.cs
- XslTransform.cs
- CodePropertyReferenceExpression.cs
- SafeCryptHandles.cs
- _SpnDictionary.cs
- MembershipUser.cs
- TypeUtils.cs
- X509Certificate.cs
- MemoryMappedFileSecurity.cs
- ControlBindingsCollection.cs
- Pool.cs
- DispatchChannelSink.cs
- LOSFormatter.cs
- WebServiceParameterData.cs
- SecurityUtils.cs
- ReferenceService.cs
- CryptographicAttribute.cs
- Expression.cs
- KnownBoxes.cs
- MsmqProcessProtocolHandler.cs
- ConstraintEnumerator.cs
- sqlcontext.cs
- EntityStoreSchemaGenerator.cs
- TypeBuilder.cs
- ResourceReader.cs
- XmlSchemaValidator.cs
- MediaContextNotificationWindow.cs
- objectquery_tresulttype.cs
- ApplicationBuildProvider.cs
- XmlSignificantWhitespace.cs
- ClientEventManager.cs
- _LocalDataStore.cs
- IteratorDescriptor.cs
- SocketElement.cs
- DispatcherFrame.cs
- ExclusiveHandle.cs
- SqlResolver.cs
- InputBinding.cs
- IArgumentProvider.cs
- ProviderCollection.cs
- Utility.cs
- DesignerTransactionCloseEvent.cs
- ReferentialConstraintRoleElement.cs
- SqlCommandSet.cs
- MatrixAnimationBase.cs
- ValidatingReaderNodeData.cs
- ServiceMemoryGates.cs
- FixedFindEngine.cs
- ScriptControl.cs
- DataGridItemCollection.cs
- RepeatInfo.cs
- SqlGatherProducedAliases.cs
- ISFTagAndGuidCache.cs
- FunctionNode.cs
- ModifiableIteratorCollection.cs
- IEnumerable.cs
- XmlSchemaSequence.cs
- SqlCommand.cs
- SHA256Managed.cs
- DeviceSpecificChoiceCollection.cs
- SmiConnection.cs
- BindingValueChangedEventArgs.cs
- AnonymousIdentificationModule.cs
- BufferedGraphics.cs
- XmlQueryTypeFactory.cs
- WeakHashtable.cs
- _TLSstream.cs
- StreamInfo.cs
- ConfigurationException.cs
- PropertyNames.cs
- GetWinFXPath.cs
- InvalidDataContractException.cs
- Monitor.cs
- SignatureDescription.cs
- FormsAuthenticationModule.cs
- SiteMapHierarchicalDataSourceView.cs
- ModulesEntry.cs
- BasicHttpMessageCredentialType.cs
- ThousandthOfEmRealPoints.cs
- Sql8ExpressionRewriter.cs
- QueryCacheManager.cs
- BaseValidatorDesigner.cs
- SqlReferenceCollection.cs
- CookieProtection.cs
- ApplicationFileCodeDomTreeGenerator.cs