Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / DynamicResourceExtensionConverter.cs / 1305600 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AuthenticationModuleElementCollection.cs
- ApplicationTrust.cs
- ColorContext.cs
- ConstraintCollection.cs
- HwndAppCommandInputProvider.cs
- Canvas.cs
- DeflateStream.cs
- SimpleHandlerBuildProvider.cs
- updatecommandorderer.cs
- XmlUTF8TextReader.cs
- AuthenticationConfig.cs
- ConfigurationManagerHelperFactory.cs
- activationcontext.cs
- ConfigXmlReader.cs
- DesignOnlyAttribute.cs
- keycontainerpermission.cs
- RootBrowserWindowProxy.cs
- EdmTypeAttribute.cs
- SubclassTypeValidator.cs
- StyleBamlRecordReader.cs
- ToolStripItemRenderEventArgs.cs
- UIElement.cs
- FormattedTextSymbols.cs
- FormViewPageEventArgs.cs
- IntegerFacetDescriptionElement.cs
- MaterialGroup.cs
- configsystem.cs
- Number.cs
- Model3DCollection.cs
- BamlTreeUpdater.cs
- SerialPort.cs
- RelatedImageListAttribute.cs
- HtmlElement.cs
- HttpCapabilitiesEvaluator.cs
- Italic.cs
- HotSpotCollection.cs
- FontCollection.cs
- DbExpressionVisitor.cs
- ToolStripRendererSwitcher.cs
- MergePropertyDescriptor.cs
- HttpHeaderCollection.cs
- ObjectConverter.cs
- ChangeProcessor.cs
- ClientScriptManagerWrapper.cs
- StoryFragments.cs
- ThaiBuddhistCalendar.cs
- PropertyItemInternal.cs
- XXXOnTypeBuilderInstantiation.cs
- DataGridViewImageCell.cs
- _MultipleConnectAsync.cs
- WebPartHeaderCloseVerb.cs
- TextSerializer.cs
- MobileListItem.cs
- TdsRecordBufferSetter.cs
- OperationCanceledException.cs
- ToolStripMenuItemDesigner.cs
- ReservationNotFoundException.cs
- TileBrush.cs
- DelegatingConfigHost.cs
- ControlPropertyNameConverter.cs
- ArrayList.cs
- ComplexLine.cs
- BaseTemplatedMobileComponentEditor.cs
- mediaclock.cs
- SectionXmlInfo.cs
- Win32.cs
- EmptyControlCollection.cs
- Pkcs7Recipient.cs
- ContainerFilterService.cs
- DbProviderConfigurationHandler.cs
- Unit.cs
- TypeDescriptionProvider.cs
- SecurityPolicySection.cs
- StateDesigner.LayoutSelectionGlyph.cs
- UntrustedRecipientException.cs
- SqlDataSourceEnumerator.cs
- MsmqEncryptionAlgorithm.cs
- SurrogateSelector.cs
- TraceSection.cs
- FormViewPageEventArgs.cs
- ComNativeDescriptor.cs
- MessageLoggingElement.cs
- MappingMetadataHelper.cs
- _KerberosClient.cs
- MediaPlayerState.cs
- BasePattern.cs
- PassportIdentity.cs
- MessageTraceRecord.cs
- ProxyGenerator.cs
- ToolStripPanel.cs
- LongValidator.cs
- Resources.Designer.cs
- WindowsToolbar.cs
- UInt64.cs
- StorageModelBuildProvider.cs
- PathGeometry.cs
- TreeNodeCollection.cs
- XmlNullResolver.cs
- CellTreeNode.cs
- PasswordRecoveryDesigner.cs