Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Markup / ProvideValueServiceProvider.cs / 1305600 / ProvideValueServiceProvider.cs
/****************************************************************************\ * * File: ProvideValueServiceProvider.cs * * ServiceProvider class that is passed into MarkupExtensions.ProvideValue method * that understands the ParserContext. * * Copyright (C) 2006 by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.Windows; using System.Windows.Media; using System.Diagnostics; namespace System.Windows.Markup { ////// Base class for all Xaml markup extensions. /// internal class ProvideValueServiceProvider : IServiceProvider, IProvideValueTarget, IXamlTypeResolver, IUriContext, IFreezeFreezables { // Construction internal ProvideValueServiceProvider(ParserContext context) { _context = context; } internal ProvideValueServiceProvider() { } // Set the TargetObject/Property (for use by IProvideValueTarget). internal void SetData(object targetObject, object targetProperty) { _targetObject = targetObject; _targetProperty = targetProperty; } // Clear the TargetObject/Property (after a call to ProvideValue) internal void ClearData() { _targetObject = _targetProperty = null; } // IXamlTypeResolver implementation Type IXamlTypeResolver.Resolve(string qualifiedTypeName) // E.g. foo:Class { return _context.XamlTypeMapper.GetTypeFromBaseString(qualifiedTypeName, _context, true); } // IProvideValueTarget implementation object IProvideValueTarget.TargetObject { get { return _targetObject; } } object IProvideValueTarget.TargetProperty { get { return _targetProperty; } } // IUriContext implementation Uri IUriContext.BaseUri { get { return _context.BaseUri; } set { throw new NotSupportedException(SR.Get(SRID.ParserProvideValueCantSetUri)); } } bool IFreezeFreezables.FreezeFreezables { get { return _context.FreezeFreezables; } } bool IFreezeFreezables.TryFreeze(string value, Freezable freezable) { return _context.TryCacheFreezable(value, freezable); } Freezable IFreezeFreezables.TryGetFreezable(string value) { return _context.TryGetFreezable(value); } // IServiceProvider implementation (this is the way to get to the // above interface implementations). public object GetService(Type service) { // IProvideValueTarget is the only implementation that // doesn't need the ParserContext if( service == typeof(IProvideValueTarget)) { return this as IProvideValueTarget; } if( _context != null ) { if( service == typeof(IXamlTypeResolver)) { return this as IXamlTypeResolver; } else if( service == typeof(IUriContext)) { return this as IUriContext; } else if (service == typeof(IFreezeFreezables)) { return this as IFreezeFreezables; } } return null; } // Data private ParserContext _context = null; private object _targetObject = null; private object _targetProperty = null; } } // 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
- DataGridViewCellEventArgs.cs
- _AutoWebProxyScriptHelper.cs
- Sql8ExpressionRewriter.cs
- PageCatalogPart.cs
- HWStack.cs
- BindableTemplateBuilder.cs
- ConditionBrowserDialog.cs
- XmlSortKeyAccumulator.cs
- ElementUtil.cs
- ObjectNavigationPropertyMapping.cs
- ModelPropertyDescriptor.cs
- InstanceDescriptor.cs
- TargetControlTypeCache.cs
- CodeTypeDeclaration.cs
- ServiceManagerHandle.cs
- OracleConnectionString.cs
- SvcMapFileSerializer.cs
- TextServicesManager.cs
- TypeListConverter.cs
- AnnotationAdorner.cs
- ParenthesizePropertyNameAttribute.cs
- CharKeyFrameCollection.cs
- TreePrinter.cs
- TextSelectionHelper.cs
- ClientTarget.cs
- SiteMap.cs
- StringCollectionMarkupSerializer.cs
- GuidelineSet.cs
- CollectionChange.cs
- MethodImplAttribute.cs
- WinHttpWebProxyFinder.cs
- MdiWindowListStrip.cs
- XmlSchemaAnyAttribute.cs
- SemaphoreFullException.cs
- InfoCardBinaryReader.cs
- BitmapSourceSafeMILHandle.cs
- XhtmlConformanceSection.cs
- UpWmlMobileTextWriter.cs
- TransactionScopeDesigner.cs
- DetailsViewDeleteEventArgs.cs
- BooleanAnimationUsingKeyFrames.cs
- HwndSubclass.cs
- DriveInfo.cs
- XamlWrappingReader.cs
- NamespaceEmitter.cs
- DbXmlEnabledProviderManifest.cs
- ping.cs
- Item.cs
- DomainUpDown.cs
- ObjectListCommandEventArgs.cs
- MsmqReceiveParameters.cs
- CacheSection.cs
- FlowNode.cs
- RetrieveVirtualItemEventArgs.cs
- DataSourceHelper.cs
- DirectoryObjectSecurity.cs
- OutputCacheProfile.cs
- JoinCqlBlock.cs
- ChannelDemuxer.cs
- HtmlFormWrapper.cs
- remotingproxy.cs
- ScriptingRoleServiceSection.cs
- DataService.cs
- CanonicalFontFamilyReference.cs
- DataGridViewRowHeaderCell.cs
- DataControlFieldsEditor.cs
- Msec.cs
- PackagePartCollection.cs
- TaskScheduler.cs
- NativeMethodsCLR.cs
- LinkClickEvent.cs
- DesignerActionMethodItem.cs
- InvalidComObjectException.cs
- ConfigurationSection.cs
- OutputCacheModule.cs
- X509ClientCertificateCredentialsElement.cs
- ColorDialog.cs
- SafeViewOfFileHandle.cs
- HashMembershipCondition.cs
- BitConverter.cs
- TemplateNameScope.cs
- PrinterResolution.cs
- OperatingSystem.cs
- KeyFrames.cs
- ServiceRouteHandler.cs
- SafeNativeMethods.cs
- SEHException.cs
- FixedPageAutomationPeer.cs
- XmlElementAttribute.cs
- Win32NamedPipes.cs
- WasAdminWrapper.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- EdmConstants.cs
- PolyBezierSegmentFigureLogic.cs
- RegistrationServices.cs
- AsymmetricSignatureFormatter.cs
- CapabilitiesRule.cs
- NotifyInputEventArgs.cs
- FolderBrowserDialogDesigner.cs
- TrustManager.cs