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
- ThemeInfoAttribute.cs
- NamespaceCollection.cs
- QueryOutputWriter.cs
- XmlSignificantWhitespace.cs
- DictionaryChange.cs
- Options.cs
- FilterElement.cs
- TitleStyle.cs
- Rotation3DAnimationBase.cs
- Connector.cs
- ScriptIgnoreAttribute.cs
- DurableTimerExtension.cs
- PeerNameRecordCollection.cs
- ResourceIDHelper.cs
- TextControl.cs
- TextElementCollectionHelper.cs
- DbProviderSpecificTypePropertyAttribute.cs
- BufferModeSettings.cs
- EventToken.cs
- DrawingState.cs
- IntranetCredentialPolicy.cs
- AssertFilter.cs
- EntityModelBuildProvider.cs
- GenericIdentity.cs
- mediaclock.cs
- NTAccount.cs
- SqlTriggerAttribute.cs
- DesignerEventService.cs
- BooleanAnimationBase.cs
- RelationshipConverter.cs
- PreservationFileWriter.cs
- FormViewUpdatedEventArgs.cs
- XmlImplementation.cs
- AvTraceFormat.cs
- Rfc2898DeriveBytes.cs
- XmlSchemaImport.cs
- RSAOAEPKeyExchangeFormatter.cs
- NetworkInformationPermission.cs
- CatalogPart.cs
- LayoutDump.cs
- TTSEngineProxy.cs
- NativeWindow.cs
- DetailsViewDeleteEventArgs.cs
- AuthenticationConfig.cs
- DataSvcMapFileSerializer.cs
- Profiler.cs
- CqlIdentifiers.cs
- SQLBoolean.cs
- MetabaseSettingsIis7.cs
- CrossContextChannel.cs
- QuaternionValueSerializer.cs
- ReadOnlyNameValueCollection.cs
- Debugger.cs
- MetadataLocation.cs
- SelectorItemAutomationPeer.cs
- PageParser.cs
- BevelBitmapEffect.cs
- RoutedPropertyChangedEventArgs.cs
- ImageInfo.cs
- DeferredReference.cs
- AssociationProvider.cs
- COM2PropertyDescriptor.cs
- SystemTcpConnection.cs
- EntitySetBase.cs
- DesignerToolStripControlHost.cs
- KnowledgeBase.cs
- DelegatingTypeDescriptionProvider.cs
- ColorAnimation.cs
- Transform3DCollection.cs
- DefaultPropertyAttribute.cs
- Cursor.cs
- PrePostDescendentsWalker.cs
- isolationinterop.cs
- RoleServiceManager.cs
- BindingMemberInfo.cs
- HMACSHA256.cs
- ObjectManager.cs
- _TransmitFileOverlappedAsyncResult.cs
- ListControl.cs
- Style.cs
- BitmapSizeOptions.cs
- ParseHttpDate.cs
- CompositeControl.cs
- RegexCode.cs
- SqlDataSourceDesigner.cs
- BinaryCommonClasses.cs
- UDPClient.cs
- ParameterCollectionEditor.cs
- BaseAsyncResult.cs
- TableSectionStyle.cs
- WebServiceEnumData.cs
- AsymmetricKeyExchangeDeformatter.cs
- RegisteredHiddenField.cs
- EpmContentSerializerBase.cs
- COM2TypeInfoProcessor.cs
- DataTable.cs
- DataGridViewTopLeftHeaderCell.cs
- HttpException.cs
- SoapInteropTypes.cs
- DetailsViewRowCollection.cs