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
- MultilineStringConverter.cs
- ListViewTableCell.cs
- SqlCachedBuffer.cs
- BindableAttribute.cs
- ToolStripDropDownItem.cs
- ArgumentException.cs
- WebService.cs
- SelectionEditingBehavior.cs
- Preprocessor.cs
- NullableDecimalAverageAggregationOperator.cs
- TriggerActionCollection.cs
- LinearKeyFrames.cs
- DbConnectionPoolIdentity.cs
- DataServiceRequestOfT.cs
- LineSegment.cs
- PointHitTestResult.cs
- ActivationArguments.cs
- SignatureResourcePool.cs
- OleDbErrorCollection.cs
- PaginationProgressEventArgs.cs
- TransformFinalBlockRequest.cs
- SparseMemoryStream.cs
- XPathSingletonIterator.cs
- FixedSOMPage.cs
- SoapMessage.cs
- GradientBrush.cs
- HtmlTextArea.cs
- MenuItemStyle.cs
- PropertyStore.cs
- ZoneLinkButton.cs
- IntegerValidatorAttribute.cs
- ItemCollection.cs
- XpsResource.cs
- GPRECT.cs
- Point4DConverter.cs
- DelayedRegex.cs
- DeploymentSection.cs
- GuidTagList.cs
- ArraySet.cs
- DataListItem.cs
- CombinedGeometry.cs
- RepeatBehavior.cs
- ByteFacetDescriptionElement.cs
- IndexingContentUnit.cs
- RuleAction.cs
- PrintDocument.cs
- DescendantBaseQuery.cs
- X509RawDataKeyIdentifierClause.cs
- Stroke2.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- XmlSchemaDatatype.cs
- LeaseManager.cs
- Knowncolors.cs
- ArraySegment.cs
- EventSinkHelperWriter.cs
- CryptoKeySecurity.cs
- Light.cs
- XmlILOptimizerVisitor.cs
- XamlPoint3DCollectionSerializer.cs
- _NegotiateClient.cs
- IsolatedStorageFilePermission.cs
- UniqueEventHelper.cs
- PaintValueEventArgs.cs
- TimelineCollection.cs
- XmlDataSource.cs
- PhysicalOps.cs
- FixedSOMFixedBlock.cs
- PeerNameResolver.cs
- TabControl.cs
- Options.cs
- LinearKeyFrames.cs
- newitemfactory.cs
- GenericTypeParameterBuilder.cs
- WhitespaceRuleLookup.cs
- CompiledQueryCacheKey.cs
- FocusWithinProperty.cs
- SystemEvents.cs
- UInt16.cs
- ISAPIWorkerRequest.cs
- ItemCheckedEvent.cs
- BuildManager.cs
- CompilerResults.cs
- DrawingAttributes.cs
- InputProcessorProfiles.cs
- HostingEnvironment.cs
- XsltInput.cs
- ContextMenuAutomationPeer.cs
- PartitionedStream.cs
- PageContentCollection.cs
- QuadraticBezierSegment.cs
- TextFormatterContext.cs
- StorageEntityTypeMapping.cs
- RuleProcessor.cs
- XmlSchemaParticle.cs
- CodeNamespaceImport.cs
- GridViewRowCollection.cs
- Expressions.cs
- ThemeableAttribute.cs
- KeyManager.cs
- ListSortDescriptionCollection.cs