Code:
/ 4.0 / 4.0 / 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.
// ==++==
//
// 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
- BatchServiceHost.cs
- ListViewItem.cs
- X509ThumbprintKeyIdentifierClause.cs
- PropertyGridView.cs
- ConfigurationElementProperty.cs
- ConfigurationSectionGroup.cs
- DiagnosticsConfiguration.cs
- CurrentTimeZone.cs
- WindowsFormsHost.cs
- OdbcConnectionHandle.cs
- StorageMappingItemCollection.cs
- HostingPreferredMapPath.cs
- Debugger.cs
- PlaceHolder.cs
- WeakRefEnumerator.cs
- ProgressBarHighlightConverter.cs
- GeneratedCodeAttribute.cs
- PreApplicationStartMethodAttribute.cs
- WindowInteractionStateTracker.cs
- UIElement3D.cs
- OutputCacheProviderCollection.cs
- cryptoapiTransform.cs
- MsmqNonTransactedPoisonHandler.cs
- PackWebResponse.cs
- EntityDataSourceState.cs
- ProfilePropertyNameValidator.cs
- DesignTimeTemplateParser.cs
- FaultReason.cs
- Logging.cs
- RegexCompilationInfo.cs
- EnumValidator.cs
- DataGridViewCellStyleConverter.cs
- Base64Stream.cs
- BitmapEncoder.cs
- SqlAggregateChecker.cs
- SegmentInfo.cs
- CustomErrorCollection.cs
- DefaultWorkflowLoaderService.cs
- GridViewDeleteEventArgs.cs
- MSAANativeProvider.cs
- Int32Storage.cs
- Run.cs
- PermissionToken.cs
- DataServiceQueryException.cs
- ProviderUtil.cs
- IdentityNotMappedException.cs
- NativeMethods.cs
- xmlformatgeneratorstatics.cs
- EntityTransaction.cs
- PeerNameRegistration.cs
- ChangeConflicts.cs
- __Error.cs
- KnownBoxes.cs
- QilVisitor.cs
- SoapInteropTypes.cs
- SystemIcons.cs
- DesignerFrame.cs
- TabletCollection.cs
- _OSSOCK.cs
- _ListenerAsyncResult.cs
- Authorization.cs
- DynamicActionMessageFilter.cs
- AsyncOperation.cs
- WebPartMovingEventArgs.cs
- XmlDataProvider.cs
- TextCharacters.cs
- FormViewRow.cs
- CellConstantDomain.cs
- ParameterCollection.cs
- LocalServiceSecuritySettingsElement.cs
- Zone.cs
- MarkupCompilePass1.cs
- PluralizationServiceUtil.cs
- EncodingInfo.cs
- ProcessingInstructionAction.cs
- CancelEventArgs.cs
- TextBoxAutoCompleteSourceConverter.cs
- SrgsDocument.cs
- DoubleCollectionConverter.cs
- Pens.cs
- SettingsProviderCollection.cs
- CodeRegionDirective.cs
- HostingEnvironmentException.cs
- ExecutedRoutedEventArgs.cs
- SubclassTypeValidator.cs
- InvalidDataException.cs
- ConstructorNeedsTagAttribute.cs
- CompiledXpathExpr.cs
- StringInfo.cs
- SecurityState.cs
- PersistencePipeline.cs
- SqlDataSourceFilteringEventArgs.cs
- ProviderCollection.cs
- HtmlForm.cs
- DataGridViewSelectedCellCollection.cs
- KeyPressEvent.cs
- XamlSerializationHelper.cs
- AttachmentCollection.cs
- _DisconnectOverlappedAsyncResult.cs
- _AutoWebProxyScriptWrapper.cs