Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / DynamicResourceExtensionConverter.cs / 1 / DynamicResourceExtensionConverter.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: ElementItem.cs // // Contents: Implements a converter to an instance descriptor for // DynamicResourceExtension // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Collections; using System.Security; using System.Text; namespace System.Windows { ////// Type converter to inform the serialization system how to construct a DynamicResourceExtension from /// an instance. It reports that ResourceKey should be used as the first parameter to the constructor. /// public class DynamicResourceExtensionConverter: TypeConverter { ////// True if converting to an instance descriptor /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ////// Converts to an instance descriptor /// ////// Critical: calls InstanceDescriptor ctor which LinkDemands /// PublicOK: can only make an InstanceDescriptor for DynamicResourceExtension, not an arbitrary class /// [SecurityCritical] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { if(value == null) throw new ArgumentNullException("value"); DynamicResourceExtension dynamicResource = value as DynamicResourceExtension; if (dynamicResource == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "DynamicResourceExtension"), "value"); return new InstanceDescriptor(typeof(DynamicResourceExtension).GetConstructor(new Type[] { typeof(object) }), new object[] { dynamicResource.ResourceKey } ); } 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: ElementItem.cs // // Contents: Implements a converter to an instance descriptor for // DynamicResourceExtension // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Collections; using System.Security; using System.Text; namespace System.Windows { ////// Type converter to inform the serialization system how to construct a DynamicResourceExtension from /// an instance. It reports that ResourceKey should be used as the first parameter to the constructor. /// public class DynamicResourceExtensionConverter: TypeConverter { ////// True if converting to an instance descriptor /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ////// Converts to an instance descriptor /// ////// Critical: calls InstanceDescriptor ctor which LinkDemands /// PublicOK: can only make an InstanceDescriptor for DynamicResourceExtension, not an arbitrary class /// [SecurityCritical] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { if(value == null) throw new ArgumentNullException("value"); DynamicResourceExtension dynamicResource = value as DynamicResourceExtension; if (dynamicResource == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "DynamicResourceExtension"), "value"); return new InstanceDescriptor(typeof(DynamicResourceExtension).GetConstructor(new Type[] { typeof(object) }), new object[] { dynamicResource.ResourceKey } ); } 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
- DockAndAnchorLayout.cs
- ColorAnimationUsingKeyFrames.cs
- Activity.cs
- SettingsAttributes.cs
- XmlNavigatorFilter.cs
- IdnMapping.cs
- RelationshipNavigation.cs
- SectionInformation.cs
- DetailsView.cs
- Cell.cs
- DataGridViewDataConnection.cs
- GestureRecognizer.cs
- TextDecoration.cs
- InstanceDataCollection.cs
- ExceptionHandlers.cs
- URI.cs
- StylusButton.cs
- Track.cs
- PropertyChangedEventArgs.cs
- SmtpFailedRecipientException.cs
- ObjectItemAssemblyLoader.cs
- ImportDesigner.xaml.cs
- DecimalAnimation.cs
- MissingManifestResourceException.cs
- DBSqlParser.cs
- QilPatternFactory.cs
- InfoCardSymmetricAlgorithm.cs
- ServiceProviders.cs
- Encoding.cs
- CacheAxisQuery.cs
- NameNode.cs
- ThrowHelper.cs
- PrimitiveOperationFormatter.cs
- Pen.cs
- FixedSOMContainer.cs
- VerticalAlignConverter.cs
- XamlStyleSerializer.cs
- Model3D.cs
- SqlLiftIndependentRowExpressions.cs
- XmlCompatibilityReader.cs
- EntityTypeEmitter.cs
- AsymmetricKeyExchangeDeformatter.cs
- KeyFrames.cs
- AuthenticatingEventArgs.cs
- IRCollection.cs
- TransportSecurityProtocolFactory.cs
- RepeatButtonAutomationPeer.cs
- ReliableMessagingVersion.cs
- BuildResultCache.cs
- IteratorDescriptor.cs
- SafeNativeMethods.cs
- _Events.cs
- updateconfighost.cs
- SqlNotificationRequest.cs
- ActivityStatusChangeEventArgs.cs
- TextDecorationLocationValidation.cs
- IsolationInterop.cs
- Base64WriteStateInfo.cs
- XmlSchemaValidationException.cs
- AppDomainGrammarProxy.cs
- StylusShape.cs
- ProfilePropertySettingsCollection.cs
- SqlMethodTransformer.cs
- MatrixKeyFrameCollection.cs
- UIAgentRequest.cs
- OrthographicCamera.cs
- PageBuildProvider.cs
- keycontainerpermission.cs
- XmlSchemaChoice.cs
- _SslSessionsCache.cs
- DetailsView.cs
- TypeDelegator.cs
- SqlDataSourceTableQuery.cs
- TemplateAction.cs
- RuntimeConfigurationRecord.cs
- Container.cs
- SchemeSettingElement.cs
- SqlStatistics.cs
- DBBindings.cs
- AutomationIdentifierGuids.cs
- SecurityManager.cs
- ServerReliableChannelBinder.cs
- HorizontalAlignConverter.cs
- ModuleConfigurationInfo.cs
- DrawingGroupDrawingContext.cs
- SingleObjectCollection.cs
- HebrewNumber.cs
- ThrowHelper.cs
- ButtonBaseAdapter.cs
- RequestCachingSection.cs
- WebControl.cs
- ApplicationException.cs
- FontDriver.cs
- EnumerableWrapperWeakToStrong.cs
- SharedUtils.cs
- ThousandthOfEmRealDoubles.cs
- RewritingProcessor.cs
- TableSectionStyle.cs
- XamlToRtfWriter.cs
- AdornerLayer.cs