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
- EventLogLink.cs
- Rss20ItemFormatter.cs
- PropertyGridView.cs
- BaseCollection.cs
- AdjustableArrowCap.cs
- Nullable.cs
- _NegoState.cs
- AppDomain.cs
- SoapReflectionImporter.cs
- RelationshipEndCollection.cs
- SubMenuStyle.cs
- WindowsTokenRoleProvider.cs
- MimeReflector.cs
- RequiredFieldValidator.cs
- SessionIDManager.cs
- ErrorRuntimeConfig.cs
- ImageConverter.cs
- OdbcException.cs
- SafeNativeMethodsMilCoreApi.cs
- ShapeTypeface.cs
- CodeLabeledStatement.cs
- MemberMemberBinding.cs
- MarshalByValueComponent.cs
- ObjectStateManager.cs
- SwitchElementsCollection.cs
- InputEventArgs.cs
- sortedlist.cs
- httpstaticobjectscollection.cs
- StyleSelector.cs
- StringFreezingAttribute.cs
- __FastResourceComparer.cs
- Rfc2898DeriveBytes.cs
- TrackBarRenderer.cs
- basenumberconverter.cs
- PartitionResolver.cs
- TypographyProperties.cs
- MonikerSyntaxException.cs
- Image.cs
- glyphs.cs
- NavigatingCancelEventArgs.cs
- TextServicesLoader.cs
- StaticSiteMapProvider.cs
- CellLabel.cs
- ColorMatrix.cs
- PreservationFileReader.cs
- PrintDialogException.cs
- PropertyGeneratedEventArgs.cs
- WebPartMenuStyle.cs
- Compress.cs
- Stackframe.cs
- BreakRecordTable.cs
- FrameworkElement.cs
- SqlIdentifier.cs
- ToolTipService.cs
- ClientConfigurationHost.cs
- DefaultValueConverter.cs
- DataControlFieldCell.cs
- WsatConfiguration.cs
- StringFormat.cs
- BindingSource.cs
- TextModifierScope.cs
- MissingManifestResourceException.cs
- XmlExceptionHelper.cs
- SqlInternalConnectionSmi.cs
- CoordinationService.cs
- PerfCounterSection.cs
- GetPageCompletedEventArgs.cs
- InputBinding.cs
- ManifestResourceInfo.cs
- MouseCaptureWithinProperty.cs
- ToolStripTextBox.cs
- IERequestCache.cs
- _NativeSSPI.cs
- LogStore.cs
- SqlDataSourceRefreshSchemaForm.cs
- CaseInsensitiveComparer.cs
- AppDomainFactory.cs
- AutomationEventArgs.cs
- DeclarationUpdate.cs
- DiagnosticTraceSource.cs
- StreamSecurityUpgradeInitiatorBase.cs
- ListControlDesigner.cs
- Transform3DGroup.cs
- PropertyGridCommands.cs
- GestureRecognizer.cs
- SoapSchemaImporter.cs
- cookie.cs
- ImageListStreamer.cs
- BinaryFormatterWriter.cs
- SchemaDeclBase.cs
- TextRangeEdit.cs
- IISMapPath.cs
- DrawingServices.cs
- RowUpdatedEventArgs.cs
- FormsIdentity.cs
- FixedSOMLineRanges.cs
- FileUpload.cs
- InfoCardArgumentException.cs
- PointLight.cs
- XamlPointCollectionSerializer.cs