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 / 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
- BitmapCacheBrush.cs
- SafeArrayTypeMismatchException.cs
- ADMembershipProvider.cs
- QuaternionValueSerializer.cs
- ExpressionBindings.cs
- SwitchLevelAttribute.cs
- ComponentChangingEvent.cs
- MessageDecoder.cs
- CompiledQueryCacheEntry.cs
- SpecialNameAttribute.cs
- EventHandlersStore.cs
- Int32CollectionConverter.cs
- LinkClickEvent.cs
- XmlILStorageConverter.cs
- ImageBrush.cs
- ObjectContext.cs
- JoinTreeNode.cs
- ExpandCollapsePattern.cs
- ControlAdapter.cs
- ProjectionPath.cs
- ExpressionEditorAttribute.cs
- PrimarySelectionGlyph.cs
- StrokeNodeOperations2.cs
- InputEventArgs.cs
- WS2007HttpBindingElement.cs
- Module.cs
- PageBuildProvider.cs
- RouteParser.cs
- ListSortDescription.cs
- RepeaterItemCollection.cs
- DesignerSerializationVisibilityAttribute.cs
- OdbcEnvironmentHandle.cs
- XPathScanner.cs
- XamlToRtfParser.cs
- MulticastOption.cs
- BindUriHelper.cs
- XslNumber.cs
- SmiEventSink.cs
- BinaryReader.cs
- SetIndexBinder.cs
- Executor.cs
- BlurBitmapEffect.cs
- BaseTemplatedMobileComponentEditor.cs
- VerificationAttribute.cs
- CodeTryCatchFinallyStatement.cs
- XmlILModule.cs
- mediaclock.cs
- ObservableCollection.cs
- VectorAnimationBase.cs
- DES.cs
- RenderContext.cs
- KeyConstraint.cs
- CodeVariableDeclarationStatement.cs
- Point4D.cs
- validationstate.cs
- FlowLayoutSettings.cs
- ZipIORawDataFileBlock.cs
- LoginCancelEventArgs.cs
- WebPartDeleteVerb.cs
- WhitespaceReader.cs
- DelegateHelpers.cs
- BigInt.cs
- TcpTransportSecurity.cs
- DeviceContexts.cs
- PassportAuthenticationModule.cs
- DataGridViewRow.cs
- ImmComposition.cs
- CorrelationTokenTypeConvertor.cs
- RangeValidator.cs
- WindowsStatusBar.cs
- SpotLight.cs
- DrawTreeNodeEventArgs.cs
- TemplateAction.cs
- AnnotationResourceCollection.cs
- UnsafeNativeMethods.cs
- NullEntityWrapper.cs
- DataGridViewControlCollection.cs
- TimeManager.cs
- MetadataItem_Static.cs
- DataSourceXmlSerializer.cs
- BindingExpressionUncommonField.cs
- ReachDocumentSequenceSerializer.cs
- XmlElementList.cs
- ReferenceEqualityComparer.cs
- Application.cs
- XmlSchemas.cs
- NativeMethods.cs
- PageMediaType.cs
- Int64Converter.cs
- WebPartsPersonalizationAuthorization.cs
- QueryProcessor.cs
- _ListenerAsyncResult.cs
- TextBlock.cs
- InputLangChangeEvent.cs
- HtmlTable.cs
- QualifiedCellIdBoolean.cs
- RelationalExpressions.cs
- BCLDebug.cs
- ToolStripGripRenderEventArgs.cs
- ToolStripGrip.cs