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
- HScrollBar.cs
- MetadataSource.cs
- PointCollection.cs
- TreeNodeCollectionEditor.cs
- Compiler.cs
- EditorResources.cs
- GetPageCompletedEventArgs.cs
- DBPropSet.cs
- Bookmark.cs
- ZipArchive.cs
- DrawingServices.cs
- StrokeIntersection.cs
- PackageRelationshipSelector.cs
- VisualStyleElement.cs
- XmlDictionary.cs
- DragEvent.cs
- SendReply.cs
- MetadataCache.cs
- DesignOnlyAttribute.cs
- CqlParserHelpers.cs
- ParserOptions.cs
- Int32AnimationBase.cs
- wgx_render.cs
- PathSegment.cs
- Floater.cs
- NodeInfo.cs
- CollectionViewProxy.cs
- RegexCode.cs
- CustomCredentialPolicy.cs
- EmissiveMaterial.cs
- RsaSecurityTokenAuthenticator.cs
- ResourcePool.cs
- OperatingSystemVersionCheck.cs
- CurrentTimeZone.cs
- State.cs
- Hyperlink.cs
- StackBuilderSink.cs
- UriExt.cs
- VisualStyleInformation.cs
- OnOperation.cs
- TextServicesDisplayAttributePropertyRanges.cs
- SafeEventHandle.cs
- CodeAccessSecurityEngine.cs
- MultiDataTrigger.cs
- Sentence.cs
- DynamicScriptObject.cs
- PeerCollaborationPermission.cs
- ClientScriptManager.cs
- DynamicControlParameter.cs
- WebConfigManager.cs
- DES.cs
- InstanceData.cs
- MsmqIntegrationMessagePool.cs
- XmlDocumentType.cs
- ImagingCache.cs
- _TimerThread.cs
- ExistsInCollection.cs
- AsymmetricKeyExchangeDeformatter.cs
- WinInetCache.cs
- Variant.cs
- TextEditor.cs
- UnsafeNativeMethods.cs
- TreeNodeCollection.cs
- MultiPageTextView.cs
- SecurityUtils.cs
- BamlBinaryReader.cs
- InvalidContentTypeException.cs
- StylusPointPropertyInfoDefaults.cs
- Invariant.cs
- TabControlAutomationPeer.cs
- DesignerProperties.cs
- DataKeyArray.cs
- WebMessageEncodingElement.cs
- TextPointerBase.cs
- TimeSpanMinutesConverter.cs
- StateMachineHelpers.cs
- TimeoutValidationAttribute.cs
- BreakRecordTable.cs
- ArrayElementGridEntry.cs
- RoutedEventArgs.cs
- RequiredAttributeAttribute.cs
- CheckBoxField.cs
- TabletDeviceInfo.cs
- TextTrailingCharacterEllipsis.cs
- OutputCacheEntry.cs
- InstallerTypeAttribute.cs
- ContextQuery.cs
- ReachSerializationUtils.cs
- FullTextBreakpoint.cs
- ToolStripDropDown.cs
- tibetanshape.cs
- RecordConverter.cs
- CustomCategoryAttribute.cs
- versioninfo.cs
- DataGridViewCellCollection.cs
- RegionIterator.cs
- SocketPermission.cs
- ResourceAttributes.cs
- DataRelation.cs
- TreeChangeInfo.cs