Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Markup / TypeExtensionConverter.cs / 1 / TypeExtensionConverter.cs
//------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation, 2005
//
// File: TypeExtensionConverter.cs
//
// Contents: Converter to convert TypeExtensions to InstanceDescriptors
// Created: 04/28/2005 [....]
//
//-----------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Collections.Generic;
using System.Text;
using System.Security;
namespace System.Windows.Markup
{
class TypeExtensionConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
{
return true;
}
return base.CanConvertTo(context, destinationType);
}
///
/// Critical: calls InstanceDescriptor ctor which LinkDemands
/// TreatAsSafe: can only make an InstanceDescriptor for TypeExtension, not an arbitrary class
///
[SecurityCritical, SecurityTreatAsSafe]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
{
TypeExtension typeExtension = value as TypeExtension;
if (typeExtension == null)
{
throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "TypeExtension"));
}
return new InstanceDescriptor(typeof(TypeExtension).GetConstructor(new Type[] { typeof(Type) }),
new object[] { typeExtension.Type });
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation, 2005
//
// File: TypeExtensionConverter.cs
//
// Contents: Converter to convert TypeExtensions to InstanceDescriptors
// Created: 04/28/2005 [....]
//
//-----------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Collections.Generic;
using System.Text;
using System.Security;
namespace System.Windows.Markup
{
class TypeExtensionConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
{
return true;
}
return base.CanConvertTo(context, destinationType);
}
///
/// Critical: calls InstanceDescriptor ctor which LinkDemands
/// TreatAsSafe: can only make an InstanceDescriptor for TypeExtension, not an arbitrary class
///
[SecurityCritical, SecurityTreatAsSafe]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
{
TypeExtension typeExtension = value as TypeExtension;
if (typeExtension == null)
{
throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "TypeExtension"));
}
return new InstanceDescriptor(typeof(TypeExtension).GetConstructor(new Type[] { typeof(Type) }),
new object[] { typeExtension.Type });
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FtpCachePolicyElement.cs
- base64Transforms.cs
- XmlSchemaSimpleTypeList.cs
- OuterGlowBitmapEffect.cs
- DispatcherExceptionFilterEventArgs.cs
- ContentDesigner.cs
- InternalBase.cs
- PropertyToken.cs
- KeyPressEvent.cs
- TextContainerChangedEventArgs.cs
- FormViewInsertEventArgs.cs
- SequenceFullException.cs
- ContentPlaceHolder.cs
- InternalEnumValidator.cs
- ValueChangedEventManager.cs
- ScrollBar.cs
- dbdatarecord.cs
- CacheEntry.cs
- ColorConverter.cs
- EnumerationRangeValidationUtil.cs
- MgmtResManager.cs
- TypeTypeConverter.cs
- CLRBindingWorker.cs
- Control.cs
- GrammarBuilderWildcard.cs
- SmtpSection.cs
- KnownTypeHelper.cs
- MeshGeometry3D.cs
- DbProviderSpecificTypePropertyAttribute.cs
- HtmlHistory.cs
- ControlPaint.cs
- ModelItemExtensions.cs
- TriState.cs
- InfoCardCryptoHelper.cs
- input.cs
- ClientRuntimeConfig.cs
- CombinedGeometry.cs
- RoutedUICommand.cs
- RuntimeWrappedException.cs
- _KerberosClient.cs
- RegexWorker.cs
- StreamInfo.cs
- CodeEntryPointMethod.cs
- TrackingMemoryStreamFactory.cs
- DirectoryInfo.cs
- WebUtil.cs
- SiteMapNodeCollection.cs
- InternalConfigSettingsFactory.cs
- listviewsubitemcollectioneditor.cs
- ToolStripLocationCancelEventArgs.cs
- CollectionChangedEventManager.cs
- DefaultAsyncDataDispatcher.cs
- PreviewKeyDownEventArgs.cs
- InstanceKeyView.cs
- MatrixTransform.cs
- EncoderExceptionFallback.cs
- HtmlControlPersistable.cs
- XmlIterators.cs
- RemotingConfiguration.cs
- SerializationObjectManager.cs
- ComponentEvent.cs
- WinEventHandler.cs
- DashStyles.cs
- JsonStringDataContract.cs
- VoiceObjectToken.cs
- SchemaInfo.cs
- HttpVersion.cs
- DockingAttribute.cs
- COAUTHINFO.cs
- ResXDataNode.cs
- NestedContainer.cs
- TextEvent.cs
- PointConverter.cs
- XmlToDatasetMap.cs
- HttpResponseMessageProperty.cs
- AdvancedBindingEditor.cs
- NegatedConstant.cs
- VectorConverter.cs
- PenCursorManager.cs
- StorageRoot.cs
- LinkLabel.cs
- DataGridViewColumnCollection.cs
- WebServiceBindingAttribute.cs
- QueryCacheEntry.cs
- ToolStripButton.cs
- HttpProfileBase.cs
- QueryCacheEntry.cs
- TcpPortSharing.cs
- Membership.cs
- SmtpException.cs
- WindowsStartMenu.cs
- BatchParser.cs
- Line.cs
- ToolZone.cs
- ReflectionTypeLoadException.cs
- DataFormats.cs
- HttpModuleCollection.cs
- CodeAttributeArgument.cs
- SqlHelper.cs
- CheckBoxField.cs