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 / 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
- OutputCacheSection.cs
- DataGridViewCellCancelEventArgs.cs
- QilLoop.cs
- UnsafeNativeMethodsCLR.cs
- hwndwrapper.cs
- ClaimTypeRequirement.cs
- httpapplicationstate.cs
- SoapParser.cs
- NameValueSectionHandler.cs
- DataGridViewCellParsingEventArgs.cs
- ValidatingPropertiesEventArgs.cs
- XmlAttributes.cs
- XslVisitor.cs
- DockPattern.cs
- UIElementCollection.cs
- CryptoProvider.cs
- SecureStringHasher.cs
- RelatedView.cs
- coordinator.cs
- PropertyManager.cs
- DataGridSortCommandEventArgs.cs
- NumericUpDown.cs
- HttpListenerResponse.cs
- PropertyPath.cs
- UpdatePanelTrigger.cs
- MetadataHelper.cs
- XmlTypeMapping.cs
- QueryOutputWriterV1.cs
- Rotation3DAnimation.cs
- Message.cs
- BooleanAnimationUsingKeyFrames.cs
- IOException.cs
- OracleParameterBinding.cs
- SqlInternalConnection.cs
- UnmanagedMemoryStreamWrapper.cs
- Wildcard.cs
- FormClosedEvent.cs
- sqlnorm.cs
- XPathAncestorIterator.cs
- EnumerableRowCollection.cs
- QilReplaceVisitor.cs
- RegexMatchCollection.cs
- CodeExpressionRuleDeclaration.cs
- querybuilder.cs
- ErasingStroke.cs
- FocusChangedEventArgs.cs
- GuidelineCollection.cs
- SupportsEventValidationAttribute.cs
- XmlUnspecifiedAttribute.cs
- Scene3D.cs
- HitTestFilterBehavior.cs
- RepeatBehaviorConverter.cs
- ProcessModuleCollection.cs
- StrongNameHelpers.cs
- ClickablePoint.cs
- CompilerGeneratedAttribute.cs
- CustomBinding.cs
- CharacterString.cs
- WebBaseEventKeyComparer.cs
- WebPartConnectionsCancelEventArgs.cs
- ActivityExecutorDelegateInfo.cs
- CheckableControlBaseAdapter.cs
- DocumentGridPage.cs
- HtmlSelectionListAdapter.cs
- DigestTraceRecordHelper.cs
- JoinGraph.cs
- Version.cs
- MenuCommands.cs
- SelectedDatesCollection.cs
- GCHandleCookieTable.cs
- FaultDesigner.cs
- SqlRetyper.cs
- WizardPanelChangingEventArgs.cs
- ReadOnlyCollection.cs
- TableParagraph.cs
- ObjectDataSourceDisposingEventArgs.cs
- CodeSnippetCompileUnit.cs
- XamlVector3DCollectionSerializer.cs
- ServerProtocol.cs
- ListParagraph.cs
- DataControlLinkButton.cs
- RuleSettingsCollection.cs
- DataTableReaderListener.cs
- ProtocolViolationException.cs
- TextEndOfLine.cs
- Config.cs
- LinqDataSource.cs
- RenamedEventArgs.cs
- NullableConverter.cs
- GlyphCache.cs
- SessionStateSection.cs
- remotingproxy.cs
- RowTypePropertyElement.cs
- ConfigurationStrings.cs
- ContentPlaceHolder.cs
- PeerName.cs
- DbParameterCollectionHelper.cs
- TransactionException.cs
- DataServiceResponse.cs
- SessionPageStatePersister.cs