Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- ListInitExpression.cs
- WizardSideBarListControlItemEventArgs.cs
- GC.cs
- ScalarConstant.cs
- FileRecordSequenceHelper.cs
- AuthenticationModeHelper.cs
- TimeSpan.cs
- BindableTemplateBuilder.cs
- XmlSchemaRedefine.cs
- EncoderReplacementFallback.cs
- TableItemStyle.cs
- XmlElementAttributes.cs
- TypeConverterAttribute.cs
- QueryContinueDragEvent.cs
- WebPartCancelEventArgs.cs
- LogReserveAndAppendState.cs
- BuiltInPermissionSets.cs
- Int64KeyFrameCollection.cs
- Rotation3DAnimation.cs
- Track.cs
- PixelShader.cs
- WindowsNonControl.cs
- TreeBuilder.cs
- ResourceWriter.cs
- InternalRelationshipCollection.cs
- DataGridView.cs
- DataControlField.cs
- Attributes.cs
- GridViewRowEventArgs.cs
- WizardStepBase.cs
- RotateTransform3D.cs
- XmlElementAttributes.cs
- CqlParser.cs
- PasswordBox.cs
- EditableRegion.cs
- CreateUserWizardDesigner.cs
- CompositeActivityTypeDescriptorProvider.cs
- FrameworkElement.cs
- SiteMapHierarchicalDataSourceView.cs
- StatusBar.cs
- ButtonField.cs
- ButtonRenderer.cs
- TreeView.cs
- XmlSignificantWhitespace.cs
- DataGridViewColumnStateChangedEventArgs.cs
- WindowsListViewSubItem.cs
- AnimationStorage.cs
- PropertyTabAttribute.cs
- NamespaceListProperty.cs
- ColorBlend.cs
- MetabaseServerConfig.cs
- TextTreeExtractElementUndoUnit.cs
- MembershipValidatePasswordEventArgs.cs
- Bits.cs
- XmlILIndex.cs
- CodeTypeOfExpression.cs
- LinqDataSourceDeleteEventArgs.cs
- TextFormatterContext.cs
- mediaclock.cs
- AppDomainFactory.cs
- AdornerPresentationContext.cs
- Misc.cs
- SendMessageChannelCache.cs
- PreApplicationStartMethodAttribute.cs
- SHA1CryptoServiceProvider.cs
- ApplicationInfo.cs
- WorkflowMessageEventHandler.cs
- TreeIterator.cs
- ExecutionEngineException.cs
- SecurityKeyIdentifierClause.cs
- NumericExpr.cs
- ArrayWithOffset.cs
- WebContentFormatHelper.cs
- WaveHeader.cs
- OrderedDictionary.cs
- Keywords.cs
- XmlElementList.cs
- UpdateException.cs
- OnOperation.cs
- ByteViewer.cs
- ObjectSecurity.cs
- RC2.cs
- MailBnfHelper.cs
- RoutedEventValueSerializer.cs
- PropertyDescriptorGridEntry.cs
- RMPublishingDialog.cs
- ScopelessEnumAttribute.cs
- DragEventArgs.cs
- StorageTypeMapping.cs
- NonParentingControl.cs
- Property.cs
- ObjectConverter.cs
- TimeoutStream.cs
- FileReservationCollection.cs
- FixedPageAutomationPeer.cs
- SerializationSectionGroup.cs
- TdsParser.cs
- InfoCardKeyedHashAlgorithm.cs
- LineBreak.cs
- DesignerAdapterUtil.cs