Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlToDatasetMap.cs
- Stack.cs
- UshortList2.cs
- ClickablePoint.cs
- EmbeddedMailObjectsCollection.cs
- SHA512Managed.cs
- ComPlusTypeLoader.cs
- DataGridColumnCollection.cs
- ReferenceEqualityComparer.cs
- SelectionChangedEventArgs.cs
- DataGridToolTip.cs
- WindowPatternIdentifiers.cs
- _CommandStream.cs
- UpDownEvent.cs
- ListChunk.cs
- DispatchOperation.cs
- TextCompositionManager.cs
- DesignerObject.cs
- TraceListeners.cs
- IncrementalCompileAnalyzer.cs
- ResourceDefaultValueAttribute.cs
- InkCanvasInnerCanvas.cs
- JsonServiceDocumentSerializer.cs
- NoResizeHandleGlyph.cs
- CodeTypeParameter.cs
- InvalidTimeZoneException.cs
- PtsPage.cs
- AccessibilityApplicationManager.cs
- KeyInstance.cs
- UnmanagedMarshal.cs
- GlyphElement.cs
- MessageAction.cs
- HttpHeaderCollection.cs
- BreakSafeBase.cs
- ParameterRetriever.cs
- LinqDataSourceHelper.cs
- CharacterMetrics.cs
- ConversionContext.cs
- DynamicValidatorEventArgs.cs
- GPStream.cs
- Array.cs
- GiveFeedbackEventArgs.cs
- TdsEnums.cs
- DropSource.cs
- COM2PictureConverter.cs
- MailAddressCollection.cs
- ToolBarButtonClickEvent.cs
- GridViewDesigner.cs
- StreamUpdate.cs
- Translator.cs
- PipeStream.cs
- XmlSchemaAttributeGroupRef.cs
- SoapConverter.cs
- AddInAdapter.cs
- SqlTriggerAttribute.cs
- BrushConverter.cs
- AttributeQuery.cs
- FlagsAttribute.cs
- Transactions.cs
- EntityModelBuildProvider.cs
- StaticExtension.cs
- ChannelBuilder.cs
- ValueUnavailableException.cs
- SqlRowUpdatedEvent.cs
- MessageFilterException.cs
- ResourceExpressionBuilder.cs
- SqlClientMetaDataCollectionNames.cs
- RoutedEvent.cs
- TypeSystem.cs
- DynamicUpdateCommand.cs
- CodeAccessSecurityEngine.cs
- GlyphsSerializer.cs
- AssociationSetMetadata.cs
- CapabilitiesPattern.cs
- OdbcRowUpdatingEvent.cs
- InputReport.cs
- DbProviderSpecificTypePropertyAttribute.cs
- DesignerProperties.cs
- TextViewBase.cs
- GeometryModel3D.cs
- GridEntry.cs
- SizeFConverter.cs
- TreeWalkHelper.cs
- XmlHelper.cs
- ResXFileRef.cs
- SerializableAttribute.cs
- CookieHandler.cs
- EventManager.cs
- ConnectivityStatus.cs
- XmlNodeChangedEventManager.cs
- MouseActionValueSerializer.cs
- FormsAuthenticationUser.cs
- smtppermission.cs
- TailPinnedEventArgs.cs
- CodeSnippetExpression.cs
- DataSourceCacheDurationConverter.cs
- ElementMarkupObject.cs
- BaseUriHelper.cs
- CodeAssignStatement.cs
- ExpressionBuilderCollection.cs