Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / TypeNameConverter.cs / 1305376 / TypeNameConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.IO; using System.Reflection; using System.Security.Permissions; using System.Xml; using System.Collections.Specialized; using System.Globalization; using System.ComponentModel; using System.Security; using System.Text; namespace System.Configuration { public sealed class TypeNameConverter : ConfigurationConverterBase { public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) { // Make the check here since for some reason value.GetType is not System.Type but RuntimeType if (!(value is Type)) { ValidateType(value, typeof(Type)); } string result = null; if (value != null) { result = ((Type)value).AssemblyQualifiedName; } return result; } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Type result = TypeUtil.GetTypeWithReflectionPermission((string)data, false); if (result == null) { throw new ArgumentException(SR.GetString(SR.Type_cannot_be_resolved, (string)data)); } return result; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.IO; using System.Reflection; using System.Security.Permissions; using System.Xml; using System.Collections.Specialized; using System.Globalization; using System.ComponentModel; using System.Security; using System.Text; namespace System.Configuration { public sealed class TypeNameConverter : ConfigurationConverterBase { public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) { // Make the check here since for some reason value.GetType is not System.Type but RuntimeType if (!(value is Type)) { ValidateType(value, typeof(Type)); } string result = null; if (value != null) { result = ((Type)value).AssemblyQualifiedName; } return result; } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Type result = TypeUtil.GetTypeWithReflectionPermission((string)data, false); if (result == null) { throw new ArgumentException(SR.GetString(SR.Type_cannot_be_resolved, (string)data)); } return result; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DesignTimeResourceProviderFactoryAttribute.cs
- HeaderedContentControl.cs
- sqlcontext.cs
- TemplateBindingExpressionConverter.cs
- DataGridComboBoxColumn.cs
- PathFigureCollectionConverter.cs
- ContentFileHelper.cs
- EventLogQuery.cs
- InvalidOleVariantTypeException.cs
- VariableAction.cs
- panel.cs
- SHA384CryptoServiceProvider.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- ImageSourceConverter.cs
- IndexOutOfRangeException.cs
- LogLogRecordEnumerator.cs
- NumericUpDownAccelerationCollection.cs
- XmlQueryOutput.cs
- DependencySource.cs
- DataGridViewCellFormattingEventArgs.cs
- StringAnimationUsingKeyFrames.cs
- MouseGestureConverter.cs
- BypassElementCollection.cs
- TreeNodeCollectionEditor.cs
- DataGridAddNewRow.cs
- WsiProfilesElement.cs
- ExtendedPropertyCollection.cs
- NativeRightsManagementAPIsStructures.cs
- DispatchChannelSink.cs
- VolatileEnlistmentMultiplexing.cs
- RightNameExpirationInfoPair.cs
- SystemWebExtensionsSectionGroup.cs
- EdmRelationshipRoleAttribute.cs
- StringArrayConverter.cs
- XmlTextWriter.cs
- SchemaTableOptionalColumn.cs
- ServiceModelStringsVersion1.cs
- PeerToPeerException.cs
- MessageOperationFormatter.cs
- GestureRecognizer.cs
- XPathNodeInfoAtom.cs
- DataListItem.cs
- InfoCardSymmetricAlgorithm.cs
- OAVariantLib.cs
- PreviewPageInfo.cs
- CommandSet.cs
- DataControlButton.cs
- HijriCalendar.cs
- DoubleAnimationClockResource.cs
- RtfFormatStack.cs
- HTTPNotFoundHandler.cs
- ObjectQuery.cs
- DeploymentSectionCache.cs
- Expression.cs
- SamlSecurityTokenAuthenticator.cs
- DependencyObjectProvider.cs
- GenericRootAutomationPeer.cs
- ArrayWithOffset.cs
- ColorBlend.cs
- CodeGenerator.cs
- KnownTypeAttribute.cs
- DataBindEngine.cs
- DataGrid.cs
- EventItfInfo.cs
- Console.cs
- MimeFormatter.cs
- SafeFileMapViewHandle.cs
- DocumentApplication.cs
- XPathBinder.cs
- XmlSerializerNamespaces.cs
- XmlSchemaSimpleTypeList.cs
- TextDecorationUnitValidation.cs
- SQLDouble.cs
- FontUnitConverter.cs
- RectangleF.cs
- X509InitiatorCertificateServiceElement.cs
- SettingsAttributes.cs
- DataGridCommandEventArgs.cs
- MemoryPressure.cs
- PasswordDeriveBytes.cs
- SmtpException.cs
- ContextMenu.cs
- XmlUrlResolver.cs
- InputMethod.cs
- GroupBox.cs
- WCFBuildProvider.cs
- UnicodeEncoding.cs
- ISAPIApplicationHost.cs
- TextDataBindingHandler.cs
- EventDescriptor.cs
- KoreanCalendar.cs
- CollectionViewProxy.cs
- HttpWebResponse.cs
- ConfigurationErrorsException.cs
- ClickablePoint.cs
- DescendentsWalker.cs
- ColumnBinding.cs
- EntityDataSourceContextCreatedEventArgs.cs
- WebPartTransformer.cs
- Switch.cs