Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Runtime / Remoting / RedirectionProxy.cs / 1305376 / RedirectionProxy.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // File: RedirectionProxy.cs using System; using System.Runtime.InteropServices; using System.Runtime.Remoting.Messaging; using System.Runtime.Remoting.Proxies; namespace System.Runtime.Remoting { internal class RedirectionProxy : MarshalByRefObject, IMessageSink { private MarshalByRefObject _proxy; [System.Security.SecurityCritical /*auto-generated*/] private RealProxy _realProxy; private Type _serverType; private WellKnownObjectMode _objectMode; [System.Security.SecurityCritical] // auto-generated internal RedirectionProxy(MarshalByRefObject proxy, Type serverType) { _proxy = proxy; _realProxy = RemotingServices.GetRealProxy(_proxy); _serverType = serverType; _objectMode = WellKnownObjectMode.Singleton; } // RedirectionProxy public WellKnownObjectMode ObjectMode { set { _objectMode = value; } } // ObjectMode [System.Security.SecurityCritical] // auto-generated public virtual IMessage SyncProcessMessage(IMessage msg) { IMessage replyMsg = null; try { msg.Properties["__Uri"] = _realProxy.IdentityObject.URI; if (_objectMode == WellKnownObjectMode.Singleton) { replyMsg = _realProxy.Invoke(msg); } else { // This is a single call object, so we need to create // a new instance. MarshalByRefObject obj = (MarshalByRefObject)Activator.CreateInstance(_serverType, true); BCLDebug.Assert(RemotingServices.IsTransparentProxy(obj), "expecting a proxy"); RealProxy rp = RemotingServices.GetRealProxy(obj); replyMsg = rp.Invoke(msg); } } catch (Exception e) { replyMsg = new ReturnMessage(e, msg as IMethodCallMessage); } return replyMsg; } // SyncProcessMessage [System.Security.SecurityCritical] // auto-generated public virtual IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink) { // < IMessage replyMsg = null; replyMsg = SyncProcessMessage(msg); if (replySink != null) replySink.SyncProcessMessage(replyMsg); return null; } // AsyncProcessMessage public IMessageSink NextSink { [System.Security.SecurityCritical] // auto-generated get { return null; } } } // class RedirectionProxy // This is only to be used for wellknown Singleton COM objects. internal class ComRedirectionProxy : MarshalByRefObject, IMessageSink { private MarshalByRefObject _comObject; private Type _serverType; internal ComRedirectionProxy(MarshalByRefObject comObject, Type serverType) { BCLDebug.Assert(serverType.IsCOMObject, "This must be a COM object type."); _comObject = comObject; _serverType = serverType; } // ComRedirectionProxy [System.Security.SecurityCritical] // auto-generated public virtual IMessage SyncProcessMessage(IMessage msg) { IMethodCallMessage mcmReqMsg = (IMethodCallMessage)msg; IMethodReturnMessage replyMsg = null; replyMsg = RemotingServices.ExecuteMessage(_comObject, mcmReqMsg); if (replyMsg != null) { // If an "RPC server not available" (HRESULT=0x800706BA) COM // exception is thrown, we will try to recreate the object once. const int RPC_S_SERVER_UNAVAILABLE = unchecked((int)0x800706BA); const int RPC_S_CALL_FAILED_DNE = unchecked((int)0x800706BF); COMException comException = replyMsg.Exception as COMException; if ((comException != null) && ((comException._HResult == RPC_S_SERVER_UNAVAILABLE) || (comException._HResult == RPC_S_CALL_FAILED_DNE))) { _comObject = (MarshalByRefObject)Activator.CreateInstance(_serverType, true); replyMsg = RemotingServices.ExecuteMessage(_comObject, mcmReqMsg); } } return replyMsg; } // SyncProcessMessage [System.Security.SecurityCritical] // auto-generated public virtual IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink) { // < IMessage replyMsg = null; replyMsg = SyncProcessMessage(msg); if (replySink != null) replySink.SyncProcessMessage(replyMsg); return null; } // AsyncProcessMessage public IMessageSink NextSink { [System.Security.SecurityCritical] // auto-generated get { return null; } } } // class ComRedirectionProxy } // namespace System.Runtime.Remoting // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TextSelectionHelper.cs
- GridPattern.cs
- BulletDecorator.cs
- DesignTimeParseData.cs
- EventDescriptor.cs
- WebSysDisplayNameAttribute.cs
- DetailsViewCommandEventArgs.cs
- SqlRecordBuffer.cs
- XD.cs
- BaseCollection.cs
- ContextProperty.cs
- HttpsHostedTransportConfiguration.cs
- WinInet.cs
- XmlTextAttribute.cs
- ProtocolsConfigurationHandler.cs
- ToolStripContentPanelDesigner.cs
- Byte.cs
- TextOutput.cs
- ConfigWriter.cs
- XmlReflectionImporter.cs
- DispatcherSynchronizationContext.cs
- ValidationResult.cs
- CustomAttributeSerializer.cs
- ChineseLunisolarCalendar.cs
- HybridWebProxyFinder.cs
- RandomDelaySendsAsyncResult.cs
- IDReferencePropertyAttribute.cs
- SmiEventSink_DeferedProcessing.cs
- InputProviderSite.cs
- AssociationSetMetadata.cs
- ThreadStartException.cs
- ProviderConnectionPoint.cs
- FileStream.cs
- GPRECT.cs
- Model3D.cs
- DetailsViewPagerRow.cs
- ObjectListFieldCollection.cs
- DataGridHeadersVisibilityToVisibilityConverter.cs
- TypeHelpers.cs
- MethodRental.cs
- TextSpanModifier.cs
- InternalControlCollection.cs
- UIElementPropertyUndoUnit.cs
- RsaElement.cs
- SchemaElementDecl.cs
- FigureParaClient.cs
- CryptographicAttribute.cs
- FlowDecision.cs
- FilteredAttributeCollection.cs
- HostProtectionPermission.cs
- XmlComplianceUtil.cs
- ListSortDescription.cs
- SingleTagSectionHandler.cs
- SettingsBase.cs
- QualifierSet.cs
- InternalControlCollection.cs
- DashStyle.cs
- BrowserDefinition.cs
- HttpCachePolicyWrapper.cs
- Permission.cs
- SecurityTokenTypes.cs
- IMembershipProvider.cs
- RegexTypeEditor.cs
- Quaternion.cs
- ActiveXContainer.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- ImageDrawing.cs
- PageCodeDomTreeGenerator.cs
- PerfProviderCollection.cs
- Util.cs
- PointUtil.cs
- DataSourceCacheDurationConverter.cs
- StrokeCollection.cs
- DecimalMinMaxAggregationOperator.cs
- ListViewDesigner.cs
- Parameter.cs
- XmlDataSourceView.cs
- CqlWriter.cs
- SpeakProgressEventArgs.cs
- StyleReferenceConverter.cs
- ApplicationServiceHelper.cs
- ArglessEventHandlerProxy.cs
- counter.cs
- DbProviderFactories.cs
- StrokeNodeOperations2.cs
- XPathScanner.cs
- ISCIIEncoding.cs
- PolicyManager.cs
- StorageTypeMapping.cs
- BitSet.cs
- SqlStream.cs
- DataGridViewControlCollection.cs
- HttpHostedTransportConfiguration.cs
- _AuthenticationState.cs
- RegexRunnerFactory.cs
- AdapterDictionary.cs
- CodeGeneratorAttribute.cs
- DetectEofStream.cs
- Animatable.cs
- TypeBuilder.cs