Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / MS / Internal / Automation / ValueProviderWrapper.cs / 1305600 / ValueProviderWrapper.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Value pattern provider wrapper for WCP // // History: // 07/21/2003 : BrendanM Ported to WCP // //--------------------------------------------------------------------------- using System; using System.Windows.Threading; using System.Windows.Media; using System.Windows.Automation; using System.Windows.Automation.Provider; using System.Windows.Automation.Peers; namespace MS.Internal.Automation { // Automation/WCP Wrapper class: Implements that UIAutomation I...Provider // interface, and calls through to a WCP AutomationPeer which implements the corresponding // I...Provider inteface. Marshalls the call from the RPC thread onto the // target AutomationPeer's context. // // Class has two major parts to it: // * Implementation of the I...Provider, which uses Dispatcher.Invoke // to call a private method (lives in second half of the class) via a delegate, // if necessary, packages any params into an object param. Return type of Invoke // must be cast from object to appropriate type. // * private methods - one for each interface entry point - which get called back // on the right context. These call through to the peer that's actually // implenting the I...Provider version of the interface. internal class ValueProviderWrapper: MarshalByRefObject, IValueProvider { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors private ValueProviderWrapper( AutomationPeer peer, IValueProvider iface ) { _peer = peer; _iface = iface; } #endregion Constructors //------------------------------------------------------ // // Interface IValueProvider // //----------------------------------------------------- #region Interface IValueProvider public void SetValue( string val ) { ElementUtil.Invoke( _peer, new DispatcherOperationCallback( SetValueInternal ), val ); } public string Value { get { return (string) ElementUtil.Invoke( _peer, new DispatcherOperationCallback( GetValue ), null ); } } public bool IsReadOnly { get { return (bool) ElementUtil.Invoke( _peer, new DispatcherOperationCallback( GetIsReadOnly ), null ); } } #endregion Interface IValueProvider //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods internal static object Wrap( AutomationPeer peer, object iface ) { return new ValueProviderWrapper( peer, (IValueProvider) iface ); } #endregion Internal Methods //----------------------------------------------------- // // Private Methods // //------------------------------------------------------ #region Private Methods private object SetValueInternal( object arg ) { _iface.SetValue( (string)arg ); return null; } private object GetValue( object unused ) { return _iface.Value; } private object GetIsReadOnly( object unused ) { return _iface.IsReadOnly; } #endregion Private Methods //----------------------------------------------------- // // Private Fields // //----------------------------------------------------- #region Private Fields private AutomationPeer _peer; private IValueProvider _iface; #endregion Private Fields } } // 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
- FrameworkElementAutomationPeer.cs
- ListViewSortEventArgs.cs
- Range.cs
- CharAnimationUsingKeyFrames.cs
- SecurityTokenSerializer.cs
- InternalBufferOverflowException.cs
- CompModSwitches.cs
- LayoutEditorPart.cs
- StylusPointPropertyId.cs
- SourceInterpreter.cs
- MonthChangedEventArgs.cs
- DrawListViewItemEventArgs.cs
- DocumentPageViewAutomationPeer.cs
- SoundPlayerAction.cs
- BitmapPalette.cs
- DataSourceXmlAttributeAttribute.cs
- XmlSerializerAssemblyAttribute.cs
- AssemblyHelper.cs
- ColumnMapTranslator.cs
- TypedDataSetSchemaImporterExtension.cs
- DataGridViewCellValueEventArgs.cs
- RawAppCommandInputReport.cs
- HtmlButton.cs
- Dictionary.cs
- ExtensibleClassFactory.cs
- DataGridToolTip.cs
- MultiView.cs
- StatusBarDrawItemEvent.cs
- DbProviderSpecificTypePropertyAttribute.cs
- NaturalLanguageHyphenator.cs
- EventItfInfo.cs
- CellLabel.cs
- SystemIPInterfaceStatistics.cs
- FigureParagraph.cs
- CodeCompileUnit.cs
- SerializationInfoEnumerator.cs
- Configuration.cs
- HttpConfigurationSystem.cs
- TimelineClockCollection.cs
- AppPool.cs
- ClientCultureInfo.cs
- QilXmlWriter.cs
- CommentGlyph.cs
- NameValueFileSectionHandler.cs
- _AutoWebProxyScriptEngine.cs
- PageHandlerFactory.cs
- BackEase.cs
- GeometryDrawing.cs
- UIElementHelper.cs
- TextLineResult.cs
- XamlPathDataSerializer.cs
- TypeConverterHelper.cs
- PageSettings.cs
- CopyCodeAction.cs
- NamespaceInfo.cs
- OdbcParameterCollection.cs
- MemberPath.cs
- NameValuePermission.cs
- ListView.cs
- ProviderUtil.cs
- DataGridViewLinkColumn.cs
- SqlCacheDependencyDatabaseCollection.cs
- SafeMarshalContext.cs
- GestureRecognizer.cs
- CodeGeneratorOptions.cs
- ModelTreeEnumerator.cs
- GridView.cs
- dataSvcMapFileLoader.cs
- ToolStripGripRenderEventArgs.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- ObjectDataSourceDisposingEventArgs.cs
- Preprocessor.cs
- RemoteWebConfigurationHost.cs
- Pkcs7Signer.cs
- EntityContainerRelationshipSetEnd.cs
- FixedTextSelectionProcessor.cs
- TypeElementCollection.cs
- QuerySetOp.cs
- ResetableIterator.cs
- SchemaNotation.cs
- RSACryptoServiceProvider.cs
- PropertyChangeTracker.cs
- SqlServices.cs
- MappedMetaModel.cs
- SQLRoleProvider.cs
- ToolstripProfessionalRenderer.cs
- XmlSchemaValidationException.cs
- TypeSystemHelpers.cs
- ProviderUtil.cs
- ISessionStateStore.cs
- cookiecontainer.cs
- DateTimeAutomationPeer.cs
- SamlAudienceRestrictionCondition.cs
- XsdCachingReader.cs
- FaultDesigner.cs
- GetPageCompletedEventArgs.cs
- CustomAssemblyResolver.cs
- LookupBindingPropertiesAttribute.cs
- FixedSOMContainer.cs
- CryptoStream.cs