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
- HwndMouseInputProvider.cs
- FlowDocumentPaginator.cs
- DataGridViewMethods.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- ControlPaint.cs
- BuildManager.cs
- EditingCoordinator.cs
- EntityProviderServices.cs
- QilParameter.cs
- AmbientLight.cs
- BitmapImage.cs
- InstanceKeyCompleteException.cs
- WorkflowApplicationIdleEventArgs.cs
- HighlightVisual.cs
- DataBindingList.cs
- TimeSpanSecondsConverter.cs
- XmlNamespaceDeclarationsAttribute.cs
- ExtensionsSection.cs
- CreationContext.cs
- DbTypeMap.cs
- ShapeTypeface.cs
- Thickness.cs
- RenderingBiasValidation.cs
- XPathQueryGenerator.cs
- ProofTokenCryptoHandle.cs
- TableProviderWrapper.cs
- MailDefinition.cs
- WindowsTitleBar.cs
- Win32Interop.cs
- NonPrimarySelectionGlyph.cs
- Light.cs
- TextDecorationLocationValidation.cs
- PropertyStore.cs
- ButtonChrome.cs
- SchemaAttDef.cs
- HitTestDrawingContextWalker.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- SmiXetterAccessMap.cs
- ExpressionBuilderCollection.cs
- StopStoryboard.cs
- securitycriticaldata.cs
- translator.cs
- TypeRestriction.cs
- ReadOnlyDataSource.cs
- CursorConverter.cs
- WmlCalendarAdapter.cs
- QilVisitor.cs
- ChangeBlockUndoRecord.cs
- ModuleBuilder.cs
- QilNode.cs
- ManualResetEvent.cs
- MultiSelector.cs
- returneventsaver.cs
- ConnectionInterfaceCollection.cs
- ModuleConfigurationInfo.cs
- SchemaImporterExtensionElementCollection.cs
- SystemColors.cs
- CodeEntryPointMethod.cs
- HashHelper.cs
- Compiler.cs
- IisTraceWebEventProvider.cs
- CombinedGeometry.cs
- ConfigXmlElement.cs
- RangeValuePatternIdentifiers.cs
- WebCategoryAttribute.cs
- TypeSystem.cs
- StaticExtension.cs
- XmlNodeWriter.cs
- FontInfo.cs
- ServiceHttpHandlerFactory.cs
- DependencyPropertyAttribute.cs
- ShapeTypeface.cs
- WebColorConverter.cs
- TabControl.cs
- SmtpCommands.cs
- KeyValueConfigurationElement.cs
- DefaultBindingPropertyAttribute.cs
- DataServiceOperationContext.cs
- BindingBase.cs
- AudioLevelUpdatedEventArgs.cs
- ControlPropertyNameConverter.cs
- TableCellCollection.cs
- CommandBinding.cs
- Enum.cs
- ToolStripDropDownClosingEventArgs.cs
- PersistChildrenAttribute.cs
- DeviceContext2.cs
- XPathDocumentBuilder.cs
- FormViewRow.cs
- ProvidePropertyAttribute.cs
- XPathEmptyIterator.cs
- HostingPreferredMapPath.cs
- SQLChars.cs
- FlowDocumentPaginator.cs
- ClickablePoint.cs
- TypeConverterHelper.cs
- PageScaling.cs
- BitmapMetadataEnumerator.cs
- RepeatInfo.cs
- NativeActivityFaultContext.cs