Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Configuration / System / Configuration / TypeNameConverter.cs / 1 / 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
- CardSpaceSelector.cs
- System.Data_BID.cs
- CfgParser.cs
- DataGridViewTextBoxColumn.cs
- Brush.cs
- ProjectionPlan.cs
- CodeComment.cs
- ValidatedControlConverter.cs
- UriGenerator.cs
- DbParameterHelper.cs
- SoapHeaders.cs
- ToolStripMenuItem.cs
- PropertyGrid.cs
- HttpStaticObjectsCollectionWrapper.cs
- PropertyConverter.cs
- NetworkCredential.cs
- RegexTree.cs
- Vector3dCollection.cs
- TableRow.cs
- UnsafeNativeMethods.cs
- EmptyStringExpandableObjectConverter.cs
- CoreSwitches.cs
- _OSSOCK.cs
- XamlSerializerUtil.cs
- RadioButton.cs
- StatusBarDesigner.cs
- HandoffBehavior.cs
- HostingEnvironmentSection.cs
- SimpleMailWebEventProvider.cs
- RowToFieldTransformer.cs
- LinkLabel.cs
- InkPresenterAutomationPeer.cs
- MsmqSecureHashAlgorithm.cs
- StaticContext.cs
- CellNormalizer.cs
- RtfToXamlLexer.cs
- MetadataArtifactLoaderCompositeFile.cs
- WindowsBrush.cs
- ContentType.cs
- RSAPKCS1KeyExchangeFormatter.cs
- AssemblyInfo.cs
- ListViewDataItem.cs
- ParallelEnumerableWrapper.cs
- DataContractFormatAttribute.cs
- NetworkInterface.cs
- DependencySource.cs
- webproxy.cs
- ExceptionValidationRule.cs
- TreeNode.cs
- InputScopeNameConverter.cs
- XmlSerializationGeneratedCode.cs
- TreeViewEvent.cs
- BinaryWriter.cs
- FixUp.cs
- FontSource.cs
- _SSPIWrapper.cs
- ChtmlLinkAdapter.cs
- FreezableOperations.cs
- Accessible.cs
- _OverlappedAsyncResult.cs
- MobileListItemCollection.cs
- InputLangChangeRequestEvent.cs
- LogAppendAsyncResult.cs
- FixedDSBuilder.cs
- BufferModeSettings.cs
- WindowsSysHeader.cs
- RefreshPropertiesAttribute.cs
- GridItemPattern.cs
- DataColumnPropertyDescriptor.cs
- ExtensionQuery.cs
- TemplateNameScope.cs
- AQNBuilder.cs
- SourceSwitch.cs
- PkcsUtils.cs
- Touch.cs
- RSACryptoServiceProvider.cs
- DynamicActivityProperty.cs
- ErrorLog.cs
- ObjectDataSource.cs
- StringValidator.cs
- CrossSiteScriptingValidation.cs
- activationcontext.cs
- UTF7Encoding.cs
- LinkTarget.cs
- ProfileService.cs
- TemplatedWizardStep.cs
- ColorDialog.cs
- DivideByZeroException.cs
- InstanceKeyCollisionException.cs
- SmtpMail.cs
- Int16.cs
- SmtpTransport.cs
- DrawingGroup.cs
- BitmapCodecInfo.cs
- XmlSerializationReader.cs
- SqlCacheDependency.cs
- baseaxisquery.cs
- SqlSupersetValidator.cs
- DependencyObjectPropertyDescriptor.cs
- DataFieldCollectionEditor.cs