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
- tooltip.cs
- PrinterUnitConvert.cs
- DataGridViewElement.cs
- StringToken.cs
- SmiSettersStream.cs
- OfTypeExpression.cs
- SqlStatistics.cs
- ButtonBaseAutomationPeer.cs
- SrgsGrammarCompiler.cs
- XamlTreeBuilder.cs
- EndpointAddress10.cs
- DrawingGroup.cs
- RecognizerBase.cs
- WebResponse.cs
- RegexReplacement.cs
- Vector.cs
- QilParameter.cs
- ThreadExceptionDialog.cs
- DataGridCheckBoxColumn.cs
- FormatConvertedBitmap.cs
- FieldToken.cs
- UIElementCollection.cs
- ITreeGenerator.cs
- DashStyle.cs
- Context.cs
- SmiXetterAccessMap.cs
- ChannelFactoryRefCache.cs
- DataGridItemCollection.cs
- EmptyStringExpandableObjectConverter.cs
- ServiceModelDictionary.cs
- TemplateBindingExtensionConverter.cs
- XmlSchemaObjectCollection.cs
- TransactionFlowBindingElementImporter.cs
- GlyphCollection.cs
- AccessibleObject.cs
- CopyOnWriteList.cs
- IndependentAnimationStorage.cs
- DialogResultConverter.cs
- _AutoWebProxyScriptHelper.cs
- CompositeControl.cs
- BamlRecordWriter.cs
- UnmanagedMemoryStream.cs
- CustomErrorsSection.cs
- TableLayoutSettingsTypeConverter.cs
- rsa.cs
- HelpInfo.cs
- RuntimeArgumentHandle.cs
- FrameworkPropertyMetadata.cs
- AmbiguousMatchException.cs
- _ConnectionGroup.cs
- ListBindingConverter.cs
- WebPartCloseVerb.cs
- MgmtResManager.cs
- BadImageFormatException.cs
- TextFormatterImp.cs
- SpeakInfo.cs
- Peer.cs
- ConfigurationValues.cs
- DefaultEventAttribute.cs
- ToolStripContentPanel.cs
- XmlWrappingReader.cs
- FileDataSourceCache.cs
- VerificationAttribute.cs
- DoubleAnimationUsingKeyFrames.cs
- RenamedEventArgs.cs
- NativeMethods.cs
- mansign.cs
- Rfc4050KeyFormatter.cs
- CodeExpressionCollection.cs
- tibetanshape.cs
- ControlAdapter.cs
- URLIdentityPermission.cs
- Rect.cs
- SrgsToken.cs
- TextServicesDisplayAttributePropertyRanges.cs
- ToolboxItem.cs
- SynchronizedDispatch.cs
- DataGridViewColumnEventArgs.cs
- SmtpDateTime.cs
- SecurityContext.cs
- Literal.cs
- PageAdapter.cs
- SqlExpressionNullability.cs
- SelectionEditingBehavior.cs
- QuaternionAnimationUsingKeyFrames.cs
- NativeMethodsOther.cs
- remotingproxy.cs
- CharacterMetricsDictionary.cs
- Variant.cs
- MemberProjectedSlot.cs
- ThicknessAnimationBase.cs
- MembershipSection.cs
- UnsafeNativeMethods.cs
- InputReport.cs
- Native.cs
- SourceLineInfo.cs
- Point3DIndependentAnimationStorage.cs
- Guid.cs
- BuildManager.cs
- SessionEndingCancelEventArgs.cs