Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / DynamicResourceExtension.cs / 1305600 / DynamicResourceExtension.cs
/****************************************************************************\ * * File: DynamicResourceExtension.cs * * Class for Xaml markup extension for static resource references. * * Copyright (C) 2004 by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.ComponentModel; using System.Windows; using System.Windows.Markup; using System.Reflection; using MS.Internal; // Helper namespace System.Windows { ////// Class for Xaml markup extension for static resource references. /// [TypeConverter(typeof(DynamicResourceExtensionConverter))] [MarkupExtensionReturnType(typeof(object))] public class DynamicResourceExtension : MarkupExtension { ////// Constructor that takes no parameters /// public DynamicResourceExtension() { } ////// Constructor that takes the resource key that this is a static reference to. /// public DynamicResourceExtension( object resourceKey) { if (resourceKey == null) { throw new ArgumentNullException("resourceKey"); } _resourceKey = resourceKey; } ////// Return an object that should be set on the targetObject's targetProperty /// for this markup extension. For DynamicResourceExtension, this is the object found in /// a resource dictionary in the current parent chain that is keyed by ResourceKey /// ////// The object to set on this property. /// public override object ProvideValue(IServiceProvider serviceProvider) { if (ResourceKey == null) { throw new InvalidOperationException(SR.Get(SRID.MarkupExtensionResourceKey)); } if (serviceProvider != null) { IProvideValueTarget provideValueTarget = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget; // DynamicResourceExtensions are not allowed On CLR props except for Setter,Trigger,Condition (bugs 1183373,1572537) DependencyObject targetDependencyObject; DependencyProperty targetDependencyProperty; Helper.CheckCanReceiveMarkupExtension(this, provideValueTarget, out targetDependencyObject, out targetDependencyProperty); } return new ResourceReferenceExpression(ResourceKey); } ////// The key in a Resource Dictionary used to find the object refered to by this /// Markup Extension. /// [ConstructorArgument("resourceKey")] // Uses an instance descriptor public object ResourceKey { get { return _resourceKey; } set { if (value == null) { throw new ArgumentNullException("value"); } _resourceKey = value; } } private object _resourceKey; } } // 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
- GeneralTransform.cs
- XmlCountingReader.cs
- BamlResourceSerializer.cs
- MessageQueueKey.cs
- ColumnCollectionEditor.cs
- BridgeDataRecord.cs
- ValidationService.cs
- OverrideMode.cs
- HWStack.cs
- SqlCommandBuilder.cs
- NullableDecimalAverageAggregationOperator.cs
- DiffuseMaterial.cs
- SafeViewOfFileHandle.cs
- EditorZone.cs
- FastPropertyAccessor.cs
- SqlConnectionPoolGroupProviderInfo.cs
- BamlStream.cs
- Pair.cs
- WebPartConnectionsConnectVerb.cs
- StsCommunicationException.cs
- TabletDeviceInfo.cs
- InheritanceContextHelper.cs
- ConfigurationValue.cs
- IsolatedStorage.cs
- StylusPointCollection.cs
- DataTemplate.cs
- Inflater.cs
- WebReferencesBuildProvider.cs
- PlaceHolder.cs
- SiteMapNodeCollection.cs
- MsmqException.cs
- TriggerBase.cs
- ExtendedProtectionPolicy.cs
- TemplatePropertyEntry.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- DefaultClaimSet.cs
- UrlPath.cs
- IssuanceLicense.cs
- InputBinding.cs
- exports.cs
- InputScopeConverter.cs
- ForeignKeyConstraint.cs
- ConstantSlot.cs
- LocationSectionRecord.cs
- DataGridViewButtonCell.cs
- ObjectDataSourceSelectingEventArgs.cs
- XamlBrushSerializer.cs
- RadioButtonPopupAdapter.cs
- TableChangeProcessor.cs
- MasterPageParser.cs
- ListViewContainer.cs
- Point.cs
- EventListener.cs
- MultipleViewProviderWrapper.cs
- XmlCustomFormatter.cs
- MouseButton.cs
- RectAnimationBase.cs
- DataGridViewCellConverter.cs
- AuthenticationConfig.cs
- LingerOption.cs
- DataGridItem.cs
- SByteStorage.cs
- FixedSOMSemanticBox.cs
- SpotLight.cs
- ScriptResourceHandler.cs
- baseshape.cs
- ParameterCollection.cs
- Rfc2898DeriveBytes.cs
- IsolatedStorage.cs
- WebColorConverter.cs
- COM2PropertyBuilderUITypeEditor.cs
- SecurityElement.cs
- Stack.cs
- OuterGlowBitmapEffect.cs
- GraphicsContainer.cs
- ResourceCategoryAttribute.cs
- SqlUnionizer.cs
- AspCompat.cs
- RegexInterpreter.cs
- FamilyTypefaceCollection.cs
- ModuleBuilderData.cs
- SectionInformation.cs
- QuaternionValueSerializer.cs
- TimeSpanSecondsConverter.cs
- PDBReader.cs
- SQlBooleanStorage.cs
- ObjectParameterCollection.cs
- VersionedStreamOwner.cs
- SqlTopReducer.cs
- safex509handles.cs
- UpdateException.cs
- FixedSOMSemanticBox.cs
- CommandValueSerializer.cs
- followingquery.cs
- Size.cs
- GenericIdentity.cs
- FormatConvertedBitmap.cs
- ProxyGenerationError.cs
- MemberHolder.cs
- FolderBrowserDialog.cs