Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / Markup / StaticExtensionConverter.cs / 1 / StaticExtensionConverter.cs
//------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation, 2005
//
// File: StaticExtensionConverter.cs
//
// Contents: Converter to convert StaticExtensions 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 StaticExtensionConverter : 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 StaticExtension, not an arbitrary class
///
[SecurityCritical, SecurityTreatAsSafe]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
{
StaticExtension staticExtension = value as StaticExtension;
if (staticExtension == null)
throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "StaticExtension"));
return new InstanceDescriptor(typeof(StaticExtension).GetConstructor(new Type[] { typeof(string) }),
new object[] { staticExtension.Member });
}
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: StaticExtensionConverter.cs
//
// Contents: Converter to convert StaticExtensions 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 StaticExtensionConverter : 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 StaticExtension, not an arbitrary class
///
[SecurityCritical, SecurityTreatAsSafe]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
{
StaticExtension staticExtension = value as StaticExtension;
if (staticExtension == null)
throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "StaticExtension"));
return new InstanceDescriptor(typeof(StaticExtension).GetConstructor(new Type[] { typeof(string) }),
new object[] { staticExtension.Member });
}
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
- InvokeSchedule.cs
- GeneralTransformGroup.cs
- NameValuePermission.cs
- GroupBoxAutomationPeer.cs
- ThemeInfoAttribute.cs
- ImmutableObjectAttribute.cs
- TemplateControlCodeDomTreeGenerator.cs
- AvtEvent.cs
- Utils.cs
- SyndicationLink.cs
- RoutedEvent.cs
- CheckedListBox.cs
- MulticastNotSupportedException.cs
- ScrollViewerAutomationPeer.cs
- TextTreeInsertElementUndoUnit.cs
- DBSqlParserTableCollection.cs
- XD.cs
- HMACSHA1.cs
- Rijndael.cs
- MissingSatelliteAssemblyException.cs
- ImplicitInputBrush.cs
- SpellerStatusTable.cs
- PersistChildrenAttribute.cs
- XXXOnTypeBuilderInstantiation.cs
- Brush.cs
- ConfigXmlAttribute.cs
- Wildcard.cs
- OleAutBinder.cs
- remotingproxy.cs
- Bidi.cs
- NameTable.cs
- PropertyGridCommands.cs
- LocatorManager.cs
- CodeNamespaceCollection.cs
- SerializationTrace.cs
- RequestResizeEvent.cs
- _ScatterGatherBuffers.cs
- LastQueryOperator.cs
- updatecommandorderer.cs
- ImageSourceTypeConverter.cs
- RepeatButton.cs
- COM2TypeInfoProcessor.cs
- BitmapSizeOptions.cs
- XXXOnTypeBuilderInstantiation.cs
- ConfigurationValue.cs
- ScalarRestriction.cs
- BaseDataListActionList.cs
- HttpServerUtilityBase.cs
- PersonalizationProvider.cs
- DateTimeUtil.cs
- SQLDecimalStorage.cs
- StrongTypingException.cs
- ScriptingProfileServiceSection.cs
- WmlImageAdapter.cs
- XsdDataContractImporter.cs
- XmlAutoDetectWriter.cs
- EntityDataSourceDesigner.cs
- CachedFontFace.cs
- DataGridTextBoxColumn.cs
- WaveHeader.cs
- LassoHelper.cs
- XomlCompiler.cs
- ModelFactory.cs
- ToggleProviderWrapper.cs
- HatchBrush.cs
- AlignmentXValidation.cs
- SHA512Managed.cs
- FullTextBreakpoint.cs
- LinearGradientBrush.cs
- BamlTreeUpdater.cs
- ReadOnlyDataSourceView.cs
- sqlmetadatafactory.cs
- RIPEMD160Managed.cs
- RuntimeCompatibilityAttribute.cs
- EmptyControlCollection.cs
- InternalsVisibleToAttribute.cs
- OracleTimeSpan.cs
- TraceUtils.cs
- SiblingIterators.cs
- DataGridViewRowCollection.cs
- SelectingProviderEventArgs.cs
- DllHostedComPlusServiceHost.cs
- XmlUtf8RawTextWriter.cs
- LinqDataSourceValidationException.cs
- InputScopeNameConverter.cs
- ServiceModelActivity.cs
- NetworkInformationPermission.cs
- PreviewKeyDownEventArgs.cs
- Missing.cs
- LoginUtil.cs
- DataErrorValidationRule.cs
- AssemblyInfo.cs
- SystemIPGlobalProperties.cs
- CryptoHandle.cs
- DBParameter.cs
- XmlSchemaCollection.cs
- WebSysDisplayNameAttribute.cs
- SoapAttributeAttribute.cs
- Point4D.cs
- VersionValidator.cs