Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- HandledMouseEvent.cs
- FileCodeGroup.cs
- Psha1DerivedKeyGeneratorHelper.cs
- ObjectDataProvider.cs
- UdpSocket.cs
- GuidConverter.cs
- SessionStateItemCollection.cs
- WorkflowInstanceSuspendedRecord.cs
- ScriptControl.cs
- XmlSchemaExporter.cs
- TextTreePropertyUndoUnit.cs
- SmtpNegotiateAuthenticationModule.cs
- ResourceIDHelper.cs
- BamlLocalizationDictionary.cs
- StreamSecurityUpgradeInitiator.cs
- CollectionEditVerbManager.cs
- x509utils.cs
- MarkedHighlightComponent.cs
- ActivityExecutor.cs
- AnimationException.cs
- DataGridViewImageColumn.cs
- XpsPackagingException.cs
- selecteditemcollection.cs
- NameValueConfigurationElement.cs
- DataServiceQueryProvider.cs
- RightsManagementInformation.cs
- SettingsAttributes.cs
- HttpDictionary.cs
- SqlVersion.cs
- ProviderConnectionPointCollection.cs
- PropertyMap.cs
- TimeoutValidationAttribute.cs
- ClientBuildManagerCallback.cs
- WindowsHyperlink.cs
- XmlHelper.cs
- BadImageFormatException.cs
- DeadCharTextComposition.cs
- WebPartUtil.cs
- MSHTMLHost.cs
- ConstructorExpr.cs
- XmlIlTypeHelper.cs
- ThreadStateException.cs
- PropertyInformationCollection.cs
- HttpHandlersSection.cs
- NameGenerator.cs
- TraceUtility.cs
- FontStretch.cs
- LoginView.cs
- COM2IDispatchConverter.cs
- TracePayload.cs
- WebPartCollection.cs
- TimeSpanValidator.cs
- WindowsListViewGroupSubsetLink.cs
- XPathNodeInfoAtom.cs
- AttachedAnnotationChangedEventArgs.cs
- ImageBrush.cs
- EventSinkHelperWriter.cs
- NativeMethods.cs
- SByte.cs
- DesignerView.cs
- EndEvent.cs
- TableAutomationPeer.cs
- InvokeHandlers.cs
- DataGridSortCommandEventArgs.cs
- Style.cs
- DbParameterCollection.cs
- Application.cs
- CanExecuteRoutedEventArgs.cs
- FontUnit.cs
- PowerEase.cs
- Tokenizer.cs
- XmlDictionaryReader.cs
- FloatUtil.cs
- ConfigurationManagerHelperFactory.cs
- ReadOnlyTernaryTree.cs
- ApplicationCommands.cs
- ContainerParaClient.cs
- SignatureToken.cs
- TextRunProperties.cs
- __Error.cs
- Translator.cs
- ObjectQuery_EntitySqlExtensions.cs
- CommandManager.cs
- EventProviderWriter.cs
- ImageAutomationPeer.cs
- UpDownBaseDesigner.cs
- VisualProxy.cs
- ConnectionsZone.cs
- _NestedSingleAsyncResult.cs
- StackBuilderSink.cs
- Pair.cs
- NotEqual.cs
- ShadowGlyph.cs
- indexingfiltermarshaler.cs
- XmlSignatureProperties.cs
- StringHelper.cs
- XPathExpr.cs
- XmlSchemaObject.cs
- DbUpdateCommandTree.cs
- RowUpdatedEventArgs.cs