Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- PartialClassGenerationTaskInternal.cs
- DoubleConverter.cs
- DataTableReaderListener.cs
- InternalUserCancelledException.cs
- StyleHelper.cs
- GiveFeedbackEvent.cs
- XmlSchemaInfo.cs
- FocusWithinProperty.cs
- HttpHandler.cs
- EdmType.cs
- DisplayNameAttribute.cs
- PublishLicense.cs
- ILGenerator.cs
- WinEventWrap.cs
- FileUtil.cs
- XmlSerializationWriter.cs
- SortedDictionary.cs
- WebBrowserUriTypeConverter.cs
- StrongName.cs
- ChangePassword.cs
- StorageEntitySetMapping.cs
- BulletedListEventArgs.cs
- TextureBrush.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- EntityParameterCollection.cs
- PrinterResolution.cs
- WindowsImpersonationContext.cs
- DoubleKeyFrameCollection.cs
- returneventsaver.cs
- Triplet.cs
- SqlNodeTypeOperators.cs
- DefaultTextStoreTextComposition.cs
- WindowsNonControl.cs
- WindowsAuthenticationEventArgs.cs
- MessageLoggingElement.cs
- TableHeaderCell.cs
- TextHidden.cs
- BasicKeyConstraint.cs
- AutomationAttributeInfo.cs
- TextDpi.cs
- HitTestFilterBehavior.cs
- FileVersionInfo.cs
- DataGridViewElement.cs
- MonthChangedEventArgs.cs
- PageContentAsyncResult.cs
- Help.cs
- BitmapMetadata.cs
- IntegrationExceptionEventArgs.cs
- RegexBoyerMoore.cs
- InvalidAsynchronousStateException.cs
- ClientBuildManagerCallback.cs
- BitVector32.cs
- DbFunctionCommandTree.cs
- ParameterCollection.cs
- MimePart.cs
- SolidBrush.cs
- MulticastDelegate.cs
- InheritanceAttribute.cs
- TableLayoutSettings.cs
- HashCodeCombiner.cs
- SmiConnection.cs
- ActivityExecutor.cs
- IdentitySection.cs
- Run.cs
- DoubleAnimation.cs
- _IPv6Address.cs
- MonthChangedEventArgs.cs
- PrintingPermission.cs
- InkCanvasInnerCanvas.cs
- DefinitionUpdate.cs
- VisemeEventArgs.cs
- ScrollChangedEventArgs.cs
- MsmqHostedTransportManager.cs
- UIPropertyMetadata.cs
- StreamAsIStream.cs
- WebPartMovingEventArgs.cs
- AnnotationComponentManager.cs
- ServiceObjectContainer.cs
- TemplateControlBuildProvider.cs
- HandlerFactoryWrapper.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- DocumentViewer.cs
- MediaTimeline.cs
- PerformanceCounter.cs
- Track.cs
- IisNotInstalledException.cs
- CodeDomSerializerBase.cs
- PermissionToken.cs
- CacheAxisQuery.cs
- IntSecurity.cs
- ScriptReferenceBase.cs
- ConfigurationErrorsException.cs
- PartialTrustVisibleAssembliesSection.cs
- ISCIIEncoding.cs
- DbCommandDefinition.cs
- ManualResetEventSlim.cs
- WebBrowser.cs
- SystemNetworkInterface.cs
- ProviderConnectionPoint.cs
- FontDifferentiator.cs