Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- Registry.cs
- ComPlusInstanceContextInitializer.cs
- GridViewItemAutomationPeer.cs
- SelectionEditingBehavior.cs
- SafeEventLogReadHandle.cs
- ScrollBarRenderer.cs
- BooleanFacetDescriptionElement.cs
- ScriptManager.cs
- ReadOnlyDictionary.cs
- xml.cs
- Viewport3DVisual.cs
- BridgeDataRecord.cs
- Transform3DGroup.cs
- StrokeNodeData.cs
- DateTime.cs
- FileNameEditor.cs
- Regex.cs
- WinInet.cs
- GuidTagList.cs
- HMACSHA384.cs
- ResourceKey.cs
- Queue.cs
- MembershipPasswordException.cs
- RSAProtectedConfigurationProvider.cs
- EFDataModelProvider.cs
- DataTableClearEvent.cs
- UnsafeNativeMethods.cs
- SaveWorkflowCommand.cs
- WebPartCatalogAddVerb.cs
- UnknownMessageReceivedEventArgs.cs
- tabpagecollectioneditor.cs
- errorpatternmatcher.cs
- SecurityUtils.cs
- DefaultBindingPropertyAttribute.cs
- AddressAlreadyInUseException.cs
- XmlSchemaAttributeGroup.cs
- ColorIndependentAnimationStorage.cs
- ToolStripKeyboardHandlingService.cs
- GlobalizationSection.cs
- Closure.cs
- ListViewPagedDataSource.cs
- Schema.cs
- TraceRecords.cs
- Visual3DCollection.cs
- DispatcherSynchronizationContext.cs
- XpsFont.cs
- NetDispatcherFaultException.cs
- FormatStringEditor.cs
- JournalEntryStack.cs
- PointLight.cs
- XPathChildIterator.cs
- CodeDirectionExpression.cs
- CrossAppDomainChannel.cs
- PresentationTraceSources.cs
- ReadOnlyTernaryTree.cs
- ElapsedEventArgs.cs
- CodeMemberField.cs
- _ScatterGatherBuffers.cs
- HttpDictionary.cs
- HtmlTable.cs
- PersonalizationEntry.cs
- AnnotationAuthorChangedEventArgs.cs
- QilIterator.cs
- DataGridViewColumn.cs
- TableCellAutomationPeer.cs
- SqlUserDefinedAggregateAttribute.cs
- Rule.cs
- EntityDataSourceStatementEditorForm.cs
- GridViewEditEventArgs.cs
- CollectionEditorDialog.cs
- C14NUtil.cs
- AppliesToBehaviorDecisionTable.cs
- HtmlInputPassword.cs
- SqlClientWrapperSmiStream.cs
- Rect.cs
- WindowsPen.cs
- ExpressionNode.cs
- InfiniteIntConverter.cs
- ConvertEvent.cs
- TransformerConfigurationWizardBase.cs
- SafeFindHandle.cs
- ToolStripItemRenderEventArgs.cs
- TextSimpleMarkerProperties.cs
- PostBackTrigger.cs
- DbgUtil.cs
- AccessViolationException.cs
- OdbcError.cs
- RC2.cs
- ConstructorNeedsTagAttribute.cs
- OracleParameterBinding.cs
- WebHttpBinding.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ValuePatternIdentifiers.cs
- TransactionInformation.cs
- FieldDescriptor.cs
- PingOptions.cs
- CleanUpVirtualizedItemEventArgs.cs
- FontFamilyIdentifier.cs
- ElasticEase.cs
- DirectoryInfo.cs