Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / DynamicResourceExtension.cs / 1 / 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. /****************************************************************************\ * * 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
- FixedTextSelectionProcessor.cs
- ToolStripItemRenderEventArgs.cs
- TdsRecordBufferSetter.cs
- ConfigurationElement.cs
- DataServiceQuery.cs
- CngUIPolicy.cs
- TrailingSpaceComparer.cs
- CollectionType.cs
- ServiceInfo.cs
- IntSecurity.cs
- EasingKeyFrames.cs
- FakeModelPropertyImpl.cs
- PositiveTimeSpanValidatorAttribute.cs
- Transaction.cs
- InputScopeAttribute.cs
- SmiGettersStream.cs
- securitycriticaldata.cs
- EntityDataSourceUtil.cs
- XappLauncher.cs
- CodeConditionStatement.cs
- PairComparer.cs
- XmlIgnoreAttribute.cs
- ListItemsPage.cs
- Enlistment.cs
- LocationUpdates.cs
- FormsAuthenticationCredentials.cs
- ObjectStorage.cs
- AsnEncodedData.cs
- ProviderConnectionPointCollection.cs
- UidManager.cs
- ContentControl.cs
- CompletedAsyncResult.cs
- System.Data.OracleClient_BID.cs
- DataConnectionHelper.cs
- TreeNodeMouseHoverEvent.cs
- CqlLexer.cs
- GroupBox.cs
- PersonalizationStateInfo.cs
- ImageConverter.cs
- formatter.cs
- MachineKeyConverter.cs
- DbDataAdapter.cs
- XmlTypeAttribute.cs
- MailWriter.cs
- ResourcesBuildProvider.cs
- RemotingConfigParser.cs
- ObjectIDGenerator.cs
- FrameworkContentElement.cs
- ToolStripSeparator.cs
- FileLevelControlBuilderAttribute.cs
- CharEnumerator.cs
- TableTextElementCollectionInternal.cs
- CryptoConfig.cs
- DataPager.cs
- TypeToken.cs
- RecognizedAudio.cs
- ResourceDisplayNameAttribute.cs
- _ListenerRequestStream.cs
- ExceptionUtil.cs
- WebBrowserSiteBase.cs
- EngineSite.cs
- BinaryFormatterWriter.cs
- ExpressionVisitor.cs
- X509Certificate2.cs
- UserNameSecurityTokenProvider.cs
- MatrixTransform3D.cs
- ProfileServiceManager.cs
- NullableLongMinMaxAggregationOperator.cs
- ImageIndexConverter.cs
- SiteMapSection.cs
- CacheChildrenQuery.cs
- MSAAWinEventWrap.cs
- XmlDataSourceView.cs
- XsltException.cs
- RuntimeTrackingProfile.cs
- WebPartConnectionsCancelEventArgs.cs
- TouchFrameEventArgs.cs
- PolyLineSegment.cs
- NativeWrapper.cs
- MemoryMappedFile.cs
- IChannel.cs
- ArgumentValidation.cs
- CodeSubDirectoriesCollection.cs
- BasicKeyConstraint.cs
- SystemIcmpV4Statistics.cs
- AnnotationComponentManager.cs
- XmlDataSourceNodeDescriptor.cs
- TextEffectResolver.cs
- Graphics.cs
- HijriCalendar.cs
- _UriTypeConverter.cs
- QueryExecutionOption.cs
- LockCookie.cs
- EdmEntityTypeAttribute.cs
- XmlUtf8RawTextWriter.cs
- QueryOptionExpression.cs
- ManagedWndProcTracker.cs
- PublisherIdentityPermission.cs
- WebServiceTypeData.cs
- securitycriticaldataClass.cs