Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / Markup / StaticExtension.cs / 1305600 / StaticExtension.cs
/****************************************************************************\ * * File: StaticExtension.cs * * Class for Xaml markup extension for static field and property references. * * Copyright (C) 2004 by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Windows.Input; using System.Reflection; using MS.Internal.WindowsBase; using MS.Utility; using System.Runtime.CompilerServices; using System.Windows.Markup; using System.Windows; namespace MS.Internal.Markup { ////// WPF wrapper for StaticExtension. Optimizes some common SystemResourceKeys & Commands /// internal class StaticExtension : System.Windows.Markup.StaticExtension { public StaticExtension() : base() { } public StaticExtension(String member) : base(member) { } ////// Return an object that should be set on the targetObject's targetProperty /// for this markup extension. For a StaticExtension this is a static field /// or property value. /// /// Object that can provide services for the markup extension. ////// The object to set on this property. /// public override object ProvideValue(IServiceProvider serviceProvider) { if (Member == null) { throw new InvalidOperationException(SR.Get(SRID.MarkupExtensionStaticMember)); } object value; if (MemberType != null) { value = SystemResourceKey.GetSystemResourceKey(MemberType.Name + "." + Member); if (value != null) { return value; } } else { value = SystemResourceKey.GetSystemResourceKey(Member); if (value != null) { return value; } // Validate the _member int dotIndex = Member.IndexOf('.'); if (dotIndex < 0) { throw new ArgumentException(SR.Get(SRID.MarkupExtensionBadStatic, Member)); } // Pull out the type substring (this will include any XML prefix, e.g. "av:Button") string typeString = Member.Substring(0, dotIndex); if (typeString == string.Empty) { throw new ArgumentException(SR.Get(SRID.MarkupExtensionBadStatic, Member)); } // Get the IXamlTypeResolver from the service provider if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } IXamlTypeResolver xamlTypeResolver = serviceProvider.GetService(typeof(IXamlTypeResolver)) as IXamlTypeResolver; if (xamlTypeResolver == null) { throw new ArgumentException(SR.Get(SRID.MarkupExtensionNoContext, GetType().Name, "IXamlTypeResolver")); } // Use the type resolver to get a Type instance MemberType = xamlTypeResolver.Resolve(typeString); // Get the member name substring Member = Member.Substring(dotIndex + 1, Member.Length - dotIndex - 1); } value = CommandConverter.GetKnownControlCommand(MemberType, Member); if (value != null) { return value; } return base.ProvideValue(serviceProvider); } } } // 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
- BeginStoryboard.cs
- Verify.cs
- SHA512CryptoServiceProvider.cs
- Contracts.cs
- QilXmlWriter.cs
- FixedSOMPage.cs
- SuppressMergeCheckAttribute.cs
- embossbitmapeffect.cs
- InternalReceiveMessage.cs
- TableRowCollection.cs
- SqlConnectionHelper.cs
- BuildManager.cs
- XmlSchemaGroupRef.cs
- DataBindingCollection.cs
- UnsafeNativeMethods.cs
- ResourceProviderFactory.cs
- HiddenFieldPageStatePersister.cs
- AttributeProviderAttribute.cs
- OpCellTreeNode.cs
- XmlWrappingReader.cs
- IDReferencePropertyAttribute.cs
- ActiveXSite.cs
- StoreItemCollection.Loader.cs
- ErrorRuntimeConfig.cs
- assemblycache.cs
- HttpProfileGroupBase.cs
- WindowsIdentity.cs
- DeferredElementTreeState.cs
- DbParameterCollection.cs
- MinimizableAttributeTypeConverter.cs
- CompiledXpathExpr.cs
- TextParagraphProperties.cs
- KeyGestureValueSerializer.cs
- TranslateTransform3D.cs
- ItemPager.cs
- VScrollProperties.cs
- DuplicateWaitObjectException.cs
- ConsoleKeyInfo.cs
- StyleModeStack.cs
- FocusWithinProperty.cs
- ServicePerformanceCounters.cs
- EncoderParameters.cs
- XmlElementAttribute.cs
- DBCSCodePageEncoding.cs
- GrabHandleGlyph.cs
- BypassElementCollection.cs
- HtmlEncodedRawTextWriter.cs
- StringAnimationBase.cs
- QueryableFilterUserControl.cs
- PenContexts.cs
- ReflectTypeDescriptionProvider.cs
- Tracking.cs
- base64Transforms.cs
- Select.cs
- basecomparevalidator.cs
- SqlClientMetaDataCollectionNames.cs
- TcpStreams.cs
- X509SubjectKeyIdentifierClause.cs
- DependencyObjectProvider.cs
- InlineObject.cs
- ProvideValueServiceProvider.cs
- PriorityItem.cs
- dbdatarecord.cs
- ComEventsMethod.cs
- RecordBuilder.cs
- NameValueConfigurationElement.cs
- EdmPropertyAttribute.cs
- FrameworkElementFactory.cs
- UnsafeNativeMethods.cs
- PageWrapper.cs
- LineInfo.cs
- SHA256.cs
- ModelTreeManager.cs
- AbsoluteQuery.cs
- DeviceSpecificChoiceCollection.cs
- Table.cs
- StylusPointCollection.cs
- GACIdentityPermission.cs
- XsltException.cs
- CallId.cs
- COM2ExtendedUITypeEditor.cs
- PartialClassGenerationTaskInternal.cs
- BinaryReader.cs
- Interop.cs
- WindowsListBox.cs
- NullableBoolConverter.cs
- HitTestWithGeometryDrawingContextWalker.cs
- WhereQueryOperator.cs
- ThemeDirectoryCompiler.cs
- WeakReference.cs
- ScaleTransform3D.cs
- MatrixTransform.cs
- RecordManager.cs
- DocumentAutomationPeer.cs
- SspiHelper.cs
- CompilerCollection.cs
- TextEditorParagraphs.cs
- Switch.cs
- DeviceContexts.cs
- AvTraceDetails.cs