Code:
/ 4.0 / 4.0 / 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. /****************************************************************************\ * * 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
- WindowsPrincipal.cs
- SymmetricAlgorithm.cs
- SchemaDeclBase.cs
- ProcessingInstructionAction.cs
- SHA384Managed.cs
- ColorTransformHelper.cs
- Models.cs
- AppDomainEvidenceFactory.cs
- Logging.cs
- AssemblyResourceLoader.cs
- EdmFunctionAttribute.cs
- TransformDescriptor.cs
- MenuItemBinding.cs
- AssemblySettingAttributes.cs
- ServiceCredentialsSecurityTokenManager.cs
- TaiwanLunisolarCalendar.cs
- DeleteHelper.cs
- Run.cs
- CustomCredentialPolicy.cs
- CodeValidator.cs
- COM2Enum.cs
- TagElement.cs
- XPathDocumentNavigator.cs
- ClaimSet.cs
- DefaultAsyncDataDispatcher.cs
- CodeTypeConstructor.cs
- CodeTypeMember.cs
- ClassicBorderDecorator.cs
- TextAnchor.cs
- HtmlInputCheckBox.cs
- X500Name.cs
- DateTimeFormat.cs
- MultipartContentParser.cs
- SocketInformation.cs
- InvokeWebServiceDesigner.cs
- BulletedListDesigner.cs
- WinFormsSpinner.cs
- TemplateKey.cs
- DispatcherExceptionEventArgs.cs
- TreeNodeCollection.cs
- SqlMethods.cs
- SolidColorBrush.cs
- SqlClientMetaDataCollectionNames.cs
- HiddenField.cs
- COM2Properties.cs
- SelectionRangeConverter.cs
- sqlinternaltransaction.cs
- HTMLTagNameToTypeMapper.cs
- ThaiBuddhistCalendar.cs
- HttpCacheVaryByContentEncodings.cs
- HttpHandler.cs
- BitHelper.cs
- GroupedContextMenuStrip.cs
- Hash.cs
- CounterSampleCalculator.cs
- VerificationAttribute.cs
- TemplateColumn.cs
- CellTreeNode.cs
- Events.cs
- DescendantOverDescendantQuery.cs
- XmlUtilWriter.cs
- PageSetupDialog.cs
- ParameterSubsegment.cs
- EndpointAddress10.cs
- CompositeCollectionView.cs
- CodeMethodInvokeExpression.cs
- WsdlWriter.cs
- InvalidDataContractException.cs
- WebServiceEnumData.cs
- EvidenceTypeDescriptor.cs
- MenuItemAutomationPeer.cs
- AnimationClock.cs
- ControlEvent.cs
- PersistenceTypeAttribute.cs
- processwaithandle.cs
- CreateUserWizardStep.cs
- WorkflowPageSetupDialog.cs
- ComPlusThreadInitializer.cs
- Scripts.cs
- GACMembershipCondition.cs
- DebugView.cs
- Rfc2898DeriveBytes.cs
- SoapFault.cs
- Symbol.cs
- Icon.cs
- ReadOnlyObservableCollection.cs
- SystemGatewayIPAddressInformation.cs
- ToolStripManager.cs
- RemoteWebConfigurationHost.cs
- Match.cs
- SelectionGlyphBase.cs
- TriggerAction.cs
- PrePostDescendentsWalker.cs
- TreeNodeCollection.cs
- EncryptedPackage.cs
- CheckBoxPopupAdapter.cs
- DerivedKeySecurityTokenStub.cs
- PermissionSetTriple.cs
- ArcSegment.cs
- ValidationHelpers.cs