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
- CustomAttributeBuilder.cs
- HttpClientChannel.cs
- TypeNameHelper.cs
- DocumentReference.cs
- BamlResourceSerializer.cs
- ObjectComplexPropertyMapping.cs
- MailWebEventProvider.cs
- TemplateKey.cs
- TcpTransportManager.cs
- SortDescription.cs
- ResourceDictionaryCollection.cs
- TitleStyle.cs
- FreezableCollection.cs
- QueryBranchOp.cs
- DataGridItemCollection.cs
- ObjectViewFactory.cs
- RSAPKCS1SignatureFormatter.cs
- ParsedAttributeCollection.cs
- ExpressionEditorAttribute.cs
- ObjectDesignerDataSourceView.cs
- DocumentGridContextMenu.cs
- CustomErrorsSection.cs
- InlineUIContainer.cs
- MethodBuilder.cs
- control.ime.cs
- CellIdBoolean.cs
- DataGridLinkButton.cs
- NavigationWindow.cs
- TreeViewImageIndexConverter.cs
- ADConnectionHelper.cs
- BuildProviderAppliesToAttribute.cs
- RSAProtectedConfigurationProvider.cs
- SqlCommandSet.cs
- TextContainer.cs
- AuthenticationSection.cs
- DataGridViewCellConverter.cs
- UnionCqlBlock.cs
- LineServicesCallbacks.cs
- Rotation3D.cs
- BuildManager.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- XmlMapping.cs
- EndOfStreamException.cs
- EnumerableRowCollection.cs
- TransactionFlowAttribute.cs
- ComboBox.cs
- XmlQueryContext.cs
- JsonReader.cs
- RtfNavigator.cs
- ElementUtil.cs
- XamlNamespaceHelper.cs
- CompilerCollection.cs
- MD5CryptoServiceProvider.cs
- GCHandleCookieTable.cs
- SparseMemoryStream.cs
- CodeCompiler.cs
- ContractsBCL.cs
- EdmRelationshipRoleAttribute.cs
- SizeValueSerializer.cs
- ObjectDataSourceView.cs
- InputScope.cs
- ToolBarButton.cs
- RawStylusInputReport.cs
- SecurityListenerSettingsLifetimeManager.cs
- RenderData.cs
- ToolStripLocationCancelEventArgs.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- XmlValidatingReaderImpl.cs
- TraceRecord.cs
- SqlCacheDependencyDatabase.cs
- ValidatedControlConverter.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- GridViewColumn.cs
- CqlLexer.cs
- GlyphCache.cs
- ServiceHostingEnvironment.cs
- SafeHandles.cs
- MemberProjectionIndex.cs
- XmlTextReader.cs
- OdbcConnectionHandle.cs
- WebRequestModuleElementCollection.cs
- CompositeActivityTypeDescriptorProvider.cs
- AssertFilter.cs
- WindowHideOrCloseTracker.cs
- SettingsBindableAttribute.cs
- DataGridViewSelectedRowCollection.cs
- LateBoundChannelParameterCollection.cs
- OleDbParameterCollection.cs
- SmiXetterAccessMap.cs
- DefaultAsyncDataDispatcher.cs
- PropertyPathWorker.cs
- TableRow.cs
- IsolatedStorageException.cs
- CmsInterop.cs
- ResolveNextArgumentWorkItem.cs
- MapPathBasedVirtualPathProvider.cs
- NotFiniteNumberException.cs
- ServiceX509SecurityTokenProvider.cs
- WebConfigurationManager.cs
- RadioButtonStandardAdapter.cs