Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- PrintDialog.cs
- SafeLibraryHandle.cs
- IPEndPointCollection.cs
- AppSettings.cs
- HttpModuleActionCollection.cs
- BitmapImage.cs
- PresentationSource.cs
- RichTextBoxAutomationPeer.cs
- CanExecuteRoutedEventArgs.cs
- Stack.cs
- ItemDragEvent.cs
- ToolStripDropTargetManager.cs
- PrePostDescendentsWalker.cs
- XmlNodeChangedEventArgs.cs
- DataSourceCacheDurationConverter.cs
- HttpDebugHandler.cs
- DefaultBindingPropertyAttribute.cs
- ZoneLinkButton.cs
- InkCanvasAutomationPeer.cs
- PersonalizationProviderHelper.cs
- MarkupCompilePass2.cs
- JsonWriter.cs
- SubstitutionResponseElement.cs
- ClonableStack.cs
- LayoutSettings.cs
- IdentityNotMappedException.cs
- SmiMetaDataProperty.cs
- SignatureDescription.cs
- AnnotationStore.cs
- CryptoKeySecurity.cs
- PrinterUnitConvert.cs
- VectorCollectionConverter.cs
- DataPagerFieldItem.cs
- VarInfo.cs
- OutputWindow.cs
- DescendantBaseQuery.cs
- XsltCompileContext.cs
- MissingManifestResourceException.cs
- AlgoModule.cs
- CacheChildrenQuery.cs
- TaskCanceledException.cs
- OleDbInfoMessageEvent.cs
- MenuEventArgs.cs
- DragEventArgs.cs
- StatusBarDrawItemEvent.cs
- DataGridViewSelectedColumnCollection.cs
- StrokeNodeEnumerator.cs
- ParseHttpDate.cs
- AgileSafeNativeMemoryHandle.cs
- HttpRuntimeSection.cs
- BamlTreeMap.cs
- MergeFailedEvent.cs
- WebScriptMetadataFormatter.cs
- SpanIndex.cs
- WebPartEventArgs.cs
- Separator.cs
- RotationValidation.cs
- ProcessInfo.cs
- Timer.cs
- InfoCardProofToken.cs
- DataTableMappingCollection.cs
- _ProxyChain.cs
- WebHttpBindingElement.cs
- TypeFieldSchema.cs
- CanonicalizationDriver.cs
- GridItemProviderWrapper.cs
- DataViewManager.cs
- PreProcessor.cs
- Transform3DGroup.cs
- FrameworkRichTextComposition.cs
- MdImport.cs
- ChannelFactoryBase.cs
- ThicknessConverter.cs
- TextParaLineResult.cs
- WindowsFormsHelpers.cs
- XPathArrayIterator.cs
- XdrBuilder.cs
- IncrementalReadDecoders.cs
- ContentValidator.cs
- TabControlEvent.cs
- TCPListener.cs
- Int32Storage.cs
- WindowsListViewScroll.cs
- WindowsTreeView.cs
- CharacterShapingProperties.cs
- TextComposition.cs
- CollectionTypeElement.cs
- XmlNamespaceManager.cs
- TableSectionStyle.cs
- AddIn.cs
- BaseServiceProvider.cs
- SolidColorBrush.cs
- InstallerTypeAttribute.cs
- Figure.cs
- SqlUdtInfo.cs
- GeneralTransform2DTo3DTo2D.cs
- OdbcCommand.cs
- AdornerHitTestResult.cs
- FontDifferentiator.cs
- CharacterBufferReference.cs