Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,22 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//=============================================================================
//
// Class: __HResults
//
// Purpose: Define HResult constants. Every exception has one of these.
//
// Date: 98/08/31 11:57:11 AM
//
//===========================================================================*/
namespace System.Runtime.Remoting {
using System;
internal sealed class __HResults
{
public const int COR_E_REMOTING = unchecked((int)0x8013150B);
public const int COR_E_SERVER = unchecked((int)0x8013150E);
}
}

View File

@@ -0,0 +1,41 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** File: __TransparentProxy.cs
**
**
** Purpose: Defines Transparent proxy
**
**
===========================================================*/
namespace System.Runtime.Remoting.Proxies {
using System.Runtime.Remoting;
// Transparent proxy and Real proxy are vital pieces of the
// remoting data structures. Transparent proxy magically
// creates a message that represents a call on it and delegates
// to the Real proxy to do the real remoting work.
using System;
internal sealed class __TransparentProxy {
// Created inside EE
private __TransparentProxy() {
throw new NotSupportedException(Environment.GetResourceString(ResId.NotSupported_Constructor));
}
// Private members called by VM
#pragma warning disable 169
[System.Security.SecurityCritical] // auto-generated
private RealProxy _rp; // Reference to the real proxy
private Object _stubData; // Data used by stubs to decide whether to short circuit calls or not
private IntPtr _pMT; // Method table of the class this proxy represents
private IntPtr _pInterfaceMT; // Cached interface method table
private IntPtr _stub; // Unmanaged code that decides whether to short circuit calls or not
#pragma warning restore 169
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,163 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Interface: AsyncResult
**
** Purpose: Object to encapsulate the results of an async
** operation
**
===========================================================*/
namespace System.Runtime.Remoting.Messaging {
using System.Threading;
using System.Runtime.Remoting;
using System;
using System.Security.Permissions;
[System.Runtime.InteropServices.ComVisible(true)]
public class AsyncResult : IAsyncResult, IMessageSink
{
[System.Security.SecurityCritical] // auto-generated
internal AsyncResult(Message m)
{
m.GetAsyncBeginInfo(out _acbd, out _asyncState);
_asyncDelegate = (Delegate) m.GetThisPtr();
}
// True if the asynchronous operation has been completed.
public virtual bool IsCompleted
{
get
{
return _isCompleted;
}
}
// The delegate object on which the async call was invoked.
public virtual Object AsyncDelegate
{
get
{
return _asyncDelegate;
}
}
// The state object passed in via BeginInvoke.
public virtual Object AsyncState
{
get
{
return _asyncState;
}
}
public virtual bool CompletedSynchronously
{
get
{
return false;
}
}
public bool EndInvokeCalled
{
get
{
return _endInvokeCalled;
}
set
{
BCLDebug.Assert(!_endInvokeCalled && value,
"EndInvoke prevents multiple calls");
_endInvokeCalled = value;
}
}
private void FaultInWaitHandle()
{
lock(this) {
if (_AsyncWaitHandle == null)
{
_AsyncWaitHandle = new ManualResetEvent(false);
}
}
}
public virtual WaitHandle AsyncWaitHandle
{
get
{
FaultInWaitHandle();
return _AsyncWaitHandle;
}
}
public virtual void SetMessageCtrl(IMessageCtrl mc)
{
_mc = mc;
}
[System.Security.SecurityCritical] // auto-generated_required
public virtual IMessage SyncProcessMessage(IMessage msg)
{
if (msg == null)
{
_replyMsg = new ReturnMessage(new RemotingException(Environment.GetResourceString("Remoting_NullMessage")), new ErrorMessage());
}
else if (!(msg is IMethodReturnMessage))
{
_replyMsg = new ReturnMessage(new RemotingException(Environment.GetResourceString("Remoting_Message_BadType")), new ErrorMessage());
}
else
{
_replyMsg = msg;
}
_isCompleted = true;
FaultInWaitHandle();
_AsyncWaitHandle.Set();
if (_acbd != null)
{
// NOTE: We are invoking user code here!
// Catch and Ignore exceptions thrown from async callback user code.
_acbd(this);
}
return null;
}
[System.Security.SecurityCritical] // auto-generated_required
public virtual IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
{
throw new NotSupportedException(
Environment.GetResourceString("NotSupported_Method"));
}
public IMessageSink NextSink
{
[System.Security.SecurityCritical] // auto-generated_required
get
{
return null;
}
}
public virtual IMessage GetReplyMessage() {return _replyMsg;}
private IMessageCtrl _mc;
private AsyncCallback _acbd;
private IMessage _replyMsg;
private bool _isCompleted;
private bool _endInvokeCalled;
private ManualResetEvent _AsyncWaitHandle;
private Delegate _asyncDelegate;
private Object _asyncState;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,476 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** File: ChannelSinkStacks.cs
**
** Purpose: Defines the stack interfaces.
**
**
===========================================================*/
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Metadata;
using System.Security.Permissions;
using System.Threading;
namespace System.Runtime.Remoting.Channels {
// interface for maintaining the sink stack
// The formatter sink MUST provide this object.
// No other sinks should have to check to see if this is null.
[System.Runtime.InteropServices.ComVisible(true)]
public interface IClientChannelSinkStack : IClientResponseChannelSinkStack
{
// Push a sink to the stack (it will be called on the way back to get
// the response stream).
[System.Security.SecurityCritical] // auto-generated_required
void Push(IClientChannelSink sink, Object state);
// Retrieve state previously pushed by sink.
[System.Security.SecurityCritical] // auto-generated_required
Object Pop(IClientChannelSink sink);
} // IChannelSinkStack
[System.Runtime.InteropServices.ComVisible(true)]
public interface IClientResponseChannelSinkStack
{
// Call AsyncProcessResponse (on previous channel sink)
[System.Security.SecurityCritical] // auto-generated_required
void AsyncProcessResponse(ITransportHeaders headers, Stream stream);
// Called by client formatter sink in AsyncProcessResponse once it has
// deserialized the response message.
[System.Security.SecurityCritical] // auto-generated_required
void DispatchReplyMessage(IMessage msg);
// If an exception happens on the async channel sink path, the
// sink should call this method with the exception.
[System.Security.SecurityCritical] // auto-generated_required
void DispatchException(Exception e);
} // interface IClientResponseChannelSinkStack
[System.Security.SecurityCritical] // auto-generated_required
[System.Runtime.InteropServices.ComVisible(true)]
public class ClientChannelSinkStack : IClientChannelSinkStack
{
private class SinkStack
{
public SinkStack PrevStack;
public IClientChannelSink Sink;
public Object State;
}
private SinkStack _stack = null;
private IMessageSink _replySink = null;
public ClientChannelSinkStack()
{
}
// use this constructor when initiating an async call
public ClientChannelSinkStack(IMessageSink replySink)
{
_replySink = replySink;
}
[System.Security.SecurityCritical]
public void Push(IClientChannelSink sink, Object state)
{
SinkStack newStack = new SinkStack();
newStack.PrevStack = _stack;
newStack.Sink = sink;
newStack.State = state;
_stack = newStack;
} // Push
// retrieve state previously pushed by sink
[System.Security.SecurityCritical]
public Object Pop(IClientChannelSink sink)
{
if (_stack == null)
{
throw new RemotingException(
Environment.GetResourceString("Remoting_Channel_PopOnEmptySinkStack"));
}
// find this sink on the stack
do
{
if (_stack.Sink == sink)
break;
_stack = _stack.PrevStack;
} while (_stack != null);
if (_stack.Sink == null)
{
throw new RemotingException(
Environment.GetResourceString("Remoting_Channel_PopFromSinkStackWithoutPush"));
}
Object state = _stack.State;
_stack = _stack.PrevStack;
return state;
} // Pop
[System.Security.SecurityCritical] // auto-generated
public void AsyncProcessResponse(ITransportHeaders headers, Stream stream)
{
// If the reply sink is null, this is a one way message, so we're not
// going to process the reply path.
if (_replySink != null)
{
if (_stack == null)
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Channel_CantCallAPRWhenStackEmpty"));
}
IClientChannelSink sink = _stack.Sink;
Object state = _stack.State;
_stack = _stack.PrevStack;
sink.AsyncProcessResponse(this, state, headers, stream);
}
} // AsyncProcessResponse
// Client formatter sink should call this in AysncProcessResponse once
// it has deserialized a message.
[System.Security.SecurityCritical] // auto-generated
public void DispatchReplyMessage(IMessage msg)
{
if (_replySink != null)
_replySink.SyncProcessMessage(msg);
} // DispatchReplyMessage
[System.Security.SecurityCritical] // auto-generated
public void DispatchException(Exception e)
{
DispatchReplyMessage(new ReturnMessage(e, null));
} // DispatchException
} // ClientChannelSinkStack
// interface for maintaining the sink stack
// The transport sink MUST provide this object.
// No other sinks should have to check to see if this is null.
[System.Runtime.InteropServices.ComVisible(true)]
public interface IServerChannelSinkStack : IServerResponseChannelSinkStack
{
// Push a sink to the stack (it will be called on the way back to get
// the response stream).
[System.Security.SecurityCritical] // auto-generated_required
void Push(IServerChannelSink sink, Object state);
// Retrieve state previously pushed by sink.
[System.Security.SecurityCritical] // auto-generated_required
Object Pop(IServerChannelSink sink);
/// <internalonly/>
// IMPORTANT: If a sink did a Push(), it must do a Pop()
// before calling GetResponseStream inside of ProcessMessage.
// On the way back, if it is determined that a asynchronous processing is
// needed, a sink should call Store() instead of Pop()
[System.Security.SecurityCritical] // auto-generated_required
void Store(IServerChannelSink sink, Object state);
/// <internalonly/>
// Called by the server transport sink to complete the dispatch, if async
// processing is being used.
[System.Security.SecurityCritical] // auto-generated_required
void StoreAndDispatch(IServerChannelSink sink, Object state);
/// <internalonly/>
// handles callback after message has been dispatched asynchronously
[System.Security.SecurityCritical] // auto-generated_required
void ServerCallback(IAsyncResult ar);
} // IServerChannelSinkStack
[System.Runtime.InteropServices.ComVisible(true)]
public interface IServerResponseChannelSinkStack
{
/// <internalonly/>
// Call AsyncProcessResponse (on previous channel sink)
[System.Security.SecurityCritical] // auto-generated_required
void AsyncProcessResponse(IMessage msg, ITransportHeaders headers, Stream stream);
// Call GetResponseStream (on previous channel sink)
[System.Security.SecurityCritical] // auto-generated_required
Stream GetResponseStream(IMessage msg, ITransportHeaders headers);
} // interface IServerResponseChannelSinkStack
[System.Security.SecurityCritical] // auto-generated_required
[System.Runtime.InteropServices.ComVisible(true)]
public class ServerChannelSinkStack : IServerChannelSinkStack
{
private class SinkStack
{
public SinkStack PrevStack;
public IServerChannelSink Sink;
public Object State;
}
private SinkStack _stack = null;
private SinkStack _rememberedStack = null;
// async callback support
private IMessage _asyncMsg = null;
private MethodInfo _asyncEnd = null;
private Object _serverObject = null;
private IMethodCallMessage _msg = null;
[System.Security.SecurityCritical]
public void Push(IServerChannelSink sink, Object state)
{
SinkStack newStack = new SinkStack();
newStack.PrevStack = _stack;
newStack.Sink = sink;
newStack.State = state;
_stack = newStack;
} // Push
[System.Security.SecurityCritical]
public Object Pop(IServerChannelSink sink)
{
if (_stack == null)
{
throw new RemotingException(
Environment.GetResourceString("Remoting_Channel_PopOnEmptySinkStack"));
}
// find this sink on the stack
do
{
if (_stack.Sink == sink)
break;
_stack = _stack.PrevStack;
} while (_stack != null);
if (_stack.Sink == null)
{
throw new RemotingException(
Environment.GetResourceString("Remoting_Channel_PopFromSinkStackWithoutPush"));
}
Object state = _stack.State;
_stack = _stack.PrevStack;
return state;
} // Pop
[System.Security.SecurityCritical] // auto-generated
public void Store(IServerChannelSink sink, Object state)
{
if (_stack == null)
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Channel_StoreOnEmptySinkStack"));
}
// find this sink on the stack
do
{
if (_stack.Sink == sink)
break;
_stack = _stack.PrevStack;
} while (_stack != null);
if (_stack.Sink == null)
{
throw new RemotingException(
Environment.GetResourceString("Remoting_Channel_StoreOnSinkStackWithoutPush"));
}
SinkStack remStack = new SinkStack();
remStack.PrevStack = _rememberedStack;
remStack.Sink = sink;
remStack.State = state;
_rememberedStack = remStack;
Pop(sink);
} // Store
[System.Security.SecurityCritical] // auto-generated
public void StoreAndDispatch(IServerChannelSink sink, Object state)
{
Store(sink, state);
FlipRememberedStack();
CrossContextChannel.DoAsyncDispatch(_asyncMsg, null);
} // Store
// Reverses remebered stack so that return message may be dispatched.
private void FlipRememberedStack()
{
if (_stack != null)
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Channel_CantCallFRSWhenStackEmtpy"));
while (_rememberedStack != null)
{
SinkStack newStack = new SinkStack();
newStack.PrevStack = _stack;
newStack.Sink = _rememberedStack.Sink;
newStack.State = _rememberedStack.State;
_stack = newStack;
_rememberedStack = _rememberedStack.PrevStack;
}
} // FlipRememberedStack
[System.Security.SecurityCritical] // auto-generated
public void AsyncProcessResponse(IMessage msg, ITransportHeaders headers, Stream stream)
{
if (_stack == null)
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Channel_CantCallAPRWhenStackEmpty"));
}
IServerChannelSink sink = _stack.Sink;
Object state = _stack.State;
_stack = _stack.PrevStack;
sink.AsyncProcessResponse(this, state, msg, headers, stream);
} // AsyncProcessResponse
[System.Security.SecurityCritical] // auto-generated
public Stream GetResponseStream(IMessage msg, ITransportHeaders headers)
{
if (_stack == null)
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Channel_CantCallGetResponseStreamWhenStackEmpty"));
}
// save state
IServerChannelSink savedSink = _stack.Sink;
Object savedState = _stack.State;
_stack = _stack.PrevStack;
Stream stream = savedSink.GetResponseStream(this, savedState, msg, headers);
// restore state
Push(savedSink, savedState);
return stream;
} // GetResponseStream
// Store server that is going to be called back
internal Object ServerObject { set { _serverObject = value; } }
[System.Security.SecurityCritical] // auto-generated
public void ServerCallback(IAsyncResult ar)
{
if (_asyncEnd != null)
{
RemotingMethodCachedData asyncEndCache = (RemotingMethodCachedData)
InternalRemotingServices.GetReflectionCachedData(_asyncEnd);
MethodInfo syncMI = (MethodInfo)_msg.MethodBase;
RemotingMethodCachedData syncCache = (RemotingMethodCachedData)
InternalRemotingServices.GetReflectionCachedData(syncMI);
ParameterInfo[] paramList = asyncEndCache.Parameters;
// construct list to pass into End
Object[] parameters = new Object[paramList.Length];
parameters[paramList.Length - 1] = ar; // last parameter is the async result
Object[] syncMsgArgs = _msg.Args;
// copy out and ref parameters to the parameters list
AsyncMessageHelper.GetOutArgs(syncCache.Parameters, syncMsgArgs, parameters);
Object[] outArgs;
StackBuilderSink s = new StackBuilderSink(_serverObject);
Object returnValue =
s.PrivateProcessMessage(_asyncEnd.MethodHandle,
System.Runtime.Remoting.Messaging.Message.CoerceArgs(_asyncEnd, parameters, paramList),
_serverObject,
out outArgs);
// The outArgs list is associated with the EndXXX method. We need to make sure
// it is sized properly for the out args of the XXX method.
if (outArgs != null)
outArgs = ArgMapper.ExpandAsyncEndArgsToSyncArgs(syncCache, outArgs);
s.CopyNonByrefOutArgsFromOriginalArgs(syncCache, syncMsgArgs, ref outArgs);
IMessage retMessage = new ReturnMessage(
returnValue, outArgs, _msg.ArgCount, Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext, _msg);
AsyncProcessResponse(retMessage, null, null);
}
} // ServerCallback
} // ServerChannelSinkStack
// helper class for transforming [....] message parameter lists into its
// async counterparts
internal static class AsyncMessageHelper
{
internal static void GetOutArgs(ParameterInfo[] syncParams, Object[] syncArgs,
Object[] endArgs)
{
int outCount = 0;
for (int co = 0; co < syncParams.Length; co++)
{
if (syncParams[co].IsOut || syncParams[co].ParameterType.IsByRef)
{
endArgs[outCount++] = syncArgs[co];
}
}
} // GetOutArgs
} // AsyncMessageHelper
} // namespace System.Runtime.Remoting.Channels

View File

@@ -0,0 +1,109 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//+----------------------------------------------------------------------------
//
// File: ClientSponsor.cs
//
// Contents: Agent for keeping Server Object's lifetime in [....] with a client's lifetime
//
// History: 8/9/00 <EMAIL>[....]</EMAIL> Created
//
//+----------------------------------------------------------------------------
namespace System.Runtime.Remoting.Lifetime
{
using System;
using System.Collections;
using System.Security.Permissions;
[System.Security.SecurityCritical] // auto-generated_required
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.Infrastructure)]
[System.Runtime.InteropServices.ComVisible(true)]
public class ClientSponsor : MarshalByRefObject, ISponsor
{
private Hashtable sponsorTable = new Hashtable(10);
private TimeSpan m_renewalTime = TimeSpan.FromMinutes(2);
public ClientSponsor()
{
}
public ClientSponsor(TimeSpan renewalTime)
{
this.m_renewalTime = renewalTime;
}
public TimeSpan RenewalTime
{
get{ return m_renewalTime;}
set{ m_renewalTime = value;}
}
[System.Security.SecurityCritical] // auto-generated
public bool Register(MarshalByRefObject obj)
{
BCLDebug.Trace("REMOTE", "ClientSponsor Register "+obj);
ILease lease = (ILease)obj.GetLifetimeService();
if (lease == null)
return false;
lease.Register(this);
lock(sponsorTable)
{
sponsorTable[obj] = lease;
}
return true;
}
[System.Security.SecurityCritical] // auto-generated
public void Unregister(MarshalByRefObject obj)
{
BCLDebug.Trace("REMOTE", "ClientSponsor Unregister "+obj);
ILease lease = null;
lock(sponsorTable)
{
lease = (ILease)sponsorTable[obj];
}
if (lease != null)
lease.Unregister(this);
}
// ISponsor method
[System.Security.SecurityCritical]
public TimeSpan Renewal(ILease lease)
{
BCLDebug.Trace("REMOTE", "ClientSponsor Renewal "+m_renewalTime);
return m_renewalTime;
}
[System.Security.SecurityCritical] // auto-generated
public void Close()
{
BCLDebug.Trace("REMOTE","ClientSponsor Close");
lock(sponsorTable)
{
IDictionaryEnumerator e = sponsorTable.GetEnumerator();
while(e.MoveNext())
((ILease)e.Value).Unregister(this);
sponsorTable.Clear();
}
}
// Don't create a lease on the sponsor
[System.Security.SecurityCritical]
public override Object InitializeLifetimeService()
{
return null;
}
[System.Security.SecuritySafeCritical] // finalizers should be treated as safe
~ClientSponsor()
{
BCLDebug.Trace("REMOTE","ClientSponsor Finalize");
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,332 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** File: ContextProperty.cs
**
** A contextProperty is a name-value pair holding the property
** name and the object representing the property in a context.
** An array of these is returned by Context::GetContextProperties()
**
**
**
===========================================================*/
namespace System.Runtime.Remoting.Contexts {
using System;
using System.Threading;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Activation;
using System.Security.Permissions;
using System.Diagnostics.Contracts;
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated_required
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.Infrastructure)]
[System.Runtime.InteropServices.ComVisible(true)]
public class ContextProperty {
internal String _name; // property name
internal Object _property; // property object
/// <internalonly/>
public virtual String Name {
get {
return _name;
}
}
/// <internalonly/>
public virtual Object Property {
get {
return _property;
}
}
/* can't create outside the package */
internal ContextProperty(String name, Object prop)
{
_name = name;
_property = prop;
}
}
// The IContextAttribute interface is implemented by attribute classes.
// The attributes contribute a property which resides in a context and
// enforces a specific policy for the objects created in that context.
/// <internalonly/>
[System.Runtime.InteropServices.ComVisible(true)]
public interface IContextAttribute
{
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated_required
bool IsContextOK(Context ctx, IConstructionCallMessage msg);
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated_required
void GetPropertiesForNewContext(IConstructionCallMessage msg);
}
// This interface is exposed by the property contributed to a context
// by an attribute. By default, it is also implemented by the ContextAttribute
// base class which every attribute class must extend from.
/// <internalonly/>
[System.Runtime.InteropServices.ComVisible(true)]
public interface IContextProperty
{
/// <internalonly/>
// This is the name under which the property will be added
// to the {name,property} table in a context.
String Name
{
[System.Security.SecurityCritical] // auto-generated_required
get;
}
/// <internalonly/>
// After forming the newCtx, we ask each property if it is happy
// with the context. We expect most implementations to say yes.
[System.Security.SecurityCritical] // auto-generated_required
bool IsNewContextOK(Context newCtx);
/// <internalonly/>
// New method. All properties are notified when the context
// they are in is frozen.
[System.Security.SecurityCritical] // auto-generated_required
void Freeze(Context newContext);
}
/// <internalonly/>
[System.Runtime.InteropServices.ComVisible(true)]
public interface IContextPropertyActivator
{
/// <internalonly/>
// This method lets properties in the current context have a say in
// whether an activation may be done 'here' or not.
[System.Security.SecurityCritical] // auto-generated_required
bool IsOKToActivate(IConstructionCallMessage msg);
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated_required
void CollectFromClientContext(IConstructionCallMessage msg);
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated_required
bool DeliverClientContextToServerContext(IConstructionCallMessage msg);
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated_required
void CollectFromServerContext(IConstructionReturnMessage msg);
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated_required
bool DeliverServerContextToClientContext(IConstructionReturnMessage msg);
}
// All context attribute classes must extend from this base class.
// This class provides the base implementations which the derived
// classes are free to over-ride. The base implementations provide
// the default answers to various questions.
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated_required
[Serializable]
[AttributeUsage(AttributeTargets.Class)]
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.Infrastructure)]
[System.Runtime.InteropServices.ComVisible(true)]
public class ContextAttribute
: Attribute, IContextAttribute, IContextProperty
{
/// <internalonly/>
protected String AttributeName;
// The derived class must call: base(name);
/// <internalonly/>
public ContextAttribute(String name)
{
AttributeName = name;
}
// IContextPropery::Name
// Default implementation provides AttributeName as the property name.
/// <internalonly/>
public virtual String Name
{
[System.Security.SecurityCritical]
get { return AttributeName; }
}
// IContextProperty::IsNewContextOK
/// <internalonly/>
[System.Security.SecurityCritical]
public virtual bool IsNewContextOK(Context newCtx)
{
// This will be called before entering the newCtx
// Default implementation says OK.
return true;
}
// IContextProperty::Freeze
// Default implementation does nothing
/// <internalonly/>
[System.Security.SecurityCritical]
public virtual void Freeze(Context newContext)
{
BCLDebug.Log("ContextAttribute::ContextProperty::Freeze"+
" for context " + newContext );
}
// Object::Equals
// Default implementation just compares the names
/// <internalonly/>
[System.Security.SecuritySafeCritical] // overrides public transparent method
public override bool Equals(Object o)
{
IContextProperty prop = o as IContextProperty;
return (null != prop) && AttributeName.Equals(prop.Name);
}
/// <internalonly/>
[System.Security.SecuritySafeCritical] // overrides public transparent method
public override int GetHashCode()
{
return this.AttributeName.GetHashCode();
}
// IContextAttribute::IsContextOK
// Default calls Object::Equals on the property and does not
// bother with the ctorMsg.
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated
public virtual bool IsContextOK(
Context ctx, IConstructionCallMessage ctorMsg)
{
if (ctx == null)
throw new ArgumentNullException("ctx");
if (ctorMsg == null)
throw new ArgumentNullException("ctorMsg");
Contract.EndContractBlock();
Contract.Assert(ctorMsg.ActivationType.IsMarshalByRef, "Activation on a non MarshalByRef object");
if (!ctorMsg.ActivationType.IsContextful)
{
return true;
}
Object prop = ctx.GetProperty(AttributeName);
if ((prop!=null) && (Equals(prop)))
{
return true;
}
return false;
}
// IContextAttribute::GetPropertiesForNewContext
// Default adds the attribute itself w/o regard to the current
// list of properties
/// <internalonly/>
[System.Security.SecurityCritical] // auto-generated
public virtual void GetPropertiesForNewContext(
IConstructionCallMessage ctorMsg)
{
if (ctorMsg == null)
throw new ArgumentNullException("ctorMsg");
Contract.EndContractBlock();
ctorMsg.ContextProperties.Add((IContextProperty)this);
}
}
#if SIMPLEXAACTIVATION
/// <internalonly/>
[AttributeUsage(AttributeTargets.Class)]
[System.Runtime.InteropServices.ComVisible(true)]
public class new_appdomain : ContextAttribute
{
internal static int _domain_no = 0;
/// <internalonly/>
public new_appdomain() : base("new_appdomain") {}
/// <internalonly/>
[System.Runtime.InteropServices.ComVisible(true)]
public override bool IsContextOK(Context ctx, IConstructionCallMessage msg)
{
return false;
}
/// <internalonly/>
[System.Runtime.InteropServices.ComVisible(true)]
public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
{
ctorMsg.GetProperties()["__new_appdomain"] = true;
}
/// <internalonly/>
[System.Runtime.InteropServices.ComVisible(true)]
public static IConstructionReturnMessage DoSimpleXADActivation(IConstructionCallMessage msg)
{
int domain_no = Interlocked.Increment(ref _domain_no);
AppDomain ad = AppDomain.CreateDomain("AutoDomain #" + domain_no, null, null);
activator a = (activator) (ad.CreateInstance(null, typeof(activator).FullName)).Unwrap();
return a.Activate(msg);
}
/// <internalonly/>
[System.Runtime.InteropServices.ComVisible(true)]
public class activator : MarshalByRefObject, IActivator
{
/// <internalonly/>
[System.Runtime.InteropServices.ComVisible(true)]
public IConstructionReturnMessage Activate(IConstructionCallMessage msg)
{
return RemotingServices.DoCrossContextActivation(msg);
}
/// <internalonly/>
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public void LoadAssembly(AssemblyName an)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
Assembly a = Assembly.InternalLoad(an, false, null, ref stackMark);
if (a == null)
{
throw new RemotingException(
String.Format(
Environment.GetResourceString(
"Remoting_AssemblyLoadFailed"),
an));
}
}
}
}
/// <internalonly/>
[new_appdomain]
[System.Runtime.InteropServices.ComVisible(true)]
public class MBR : MarshalByRefObject
{
/// <internalonly/>
public String MyAppDomain()
{
return Thread.GetDomain().GetFriendlyName();
}
}
/// <internalonly/>
[new_appdomain]
[System.Runtime.InteropServices.ComVisible(true)]
public class CB : ContextBoundObject
{
/// <internalonly/>
public String MyAppDomain()
{
return Thread.GetDomain().GetFriendlyName();
}
}
#endif
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,116 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// File: DispatchChannelSink.cs
using System;
using System.Collections;
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Diagnostics.Contracts;
namespace System.Runtime.Remoting.Channels
{
internal class DispatchChannelSinkProvider : IServerChannelSinkProvider
{
internal DispatchChannelSinkProvider()
{
} // DispatchChannelSinkProvider
[System.Security.SecurityCritical] // auto-generated
public void GetChannelData(IChannelDataStore channelData)
{
}
[System.Security.SecurityCritical] // auto-generated
public IServerChannelSink CreateSink(IChannelReceiver channel)
{
return new DispatchChannelSink();
}
public IServerChannelSinkProvider Next
{
[System.Security.SecurityCritical] // auto-generated
get { return null; }
[System.Security.SecurityCritical] // auto-generated
set { throw new NotSupportedException(); }
}
} // class DispatchChannelSinkProvider
internal class DispatchChannelSink : IServerChannelSink
{
internal DispatchChannelSink()
{
} // DispatchChannelSink
[System.Security.SecurityCritical] // auto-generated
public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack,
IMessage requestMsg,
ITransportHeaders requestHeaders, Stream requestStream,
out IMessage responseMsg, out ITransportHeaders responseHeaders,
out Stream responseStream)
{
if (requestMsg == null)
{
throw new ArgumentNullException(
"requestMsg",
Environment.GetResourceString("Remoting_Channel_DispatchSinkMessageMissing"));
}
Contract.EndContractBlock();
// check arguments
if (requestStream != null)
{
throw new RemotingException(
Environment.GetResourceString("Remoting_Channel_DispatchSinkWantsNullRequestStream"));
}
responseHeaders = null;
responseStream = null;
return ChannelServices.DispatchMessage(sinkStack, requestMsg, out responseMsg);
} // ProcessMessage
[System.Security.SecurityCritical] // auto-generated
public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, Object state,
IMessage msg, ITransportHeaders headers, Stream stream)
{
// We never push ourselves to the sink stack, so this won't be called.
throw new NotSupportedException();
} // AsyncProcessResponse
[System.Security.SecurityCritical] // auto-generated
public Stream GetResponseStream(IServerResponseChannelSinkStack sinkStack, Object state,
IMessage msg, ITransportHeaders headers)
{
// We never push ourselves to the sink stack, so this won't be called.
throw new NotSupportedException();
} // GetResponseStream
public IServerChannelSink NextChannelSink
{
[System.Security.SecurityCritical] // auto-generated
get { return null; }
}
public IDictionary Properties
{
[System.Security.SecurityCritical] // auto-generated
get { return null; }
}
} // class DispatchChannelSink
} // namespace System.Runtime.Remoting.Channels

View File

@@ -0,0 +1,222 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//
// DynamicPropertyHolder manages the dynamically registered properties
// and the sinks contributed by them. Dynamic properties may be registered
// to contribute sinks on a per-object basis (on the proxy or server side)
// or on a per-Context basis (in both the client and server contexts).
//
// See also: RemotingServices.RegisterDynamicSink() API
//
namespace System.Runtime.Remoting.Contexts {
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System;
using System.Collections;
using System.Globalization;
internal class DynamicPropertyHolder
{
private const int GROW_BY = 0x8;
private IDynamicProperty[] _props;
private int _numProps;
private IDynamicMessageSink[] _sinks;
[System.Security.SecurityCritical] // auto-generated
internal virtual bool AddDynamicProperty(IDynamicProperty prop)
{
lock(this) {
// We have to add a sink specific to the given context
CheckPropertyNameClash(prop.Name, _props, _numProps);
// check if we need to grow the array.
bool bGrow=false;
if (_props == null || _numProps == _props.Length)
{
_props = GrowPropertiesArray(_props);
bGrow = true;
}
// now add the property
_props[_numProps++] = prop;
// we need to grow the sinks if we grew the props array or we had thrown
// away the sinks array due to a recent removal!
if (bGrow)
{
_sinks = GrowDynamicSinksArray(_sinks);
}
if (_sinks == null)
{
// Some property got unregistered -- we need to recreate
// the list of sinks.
_sinks = new IDynamicMessageSink[_props.Length];
for (int i=0; i<_numProps; i++)
{
_sinks[i] =
((IContributeDynamicSink)_props[i]).GetDynamicSink();
}
}
else
{
// append the Sink to the existing array of Sinks
_sinks[_numProps-1] =
((IContributeDynamicSink)prop).GetDynamicSink();
}
return true;
}
}
[System.Security.SecurityCritical] // auto-generated
internal virtual bool RemoveDynamicProperty(String name)
{
lock(this) {
// We have to remove a property for a specific context
for (int i=0; i<_numProps; i++)
{
if (_props[i].Name.Equals(name))
{
_props[i] = _props[_numProps-1];
_numProps--;
// throw away the dynamic sink list
_sinks = null;
return true;
}
}
throw new RemotingException(
String.Format(
CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Contexts_NoProperty"),
name));
}
}
internal virtual IDynamicProperty[] DynamicProperties
{
get
{
if (_props == null)
{
return null;
}
lock (this)
{
IDynamicProperty[] retProps = new IDynamicProperty[_numProps];
Array.Copy(_props, retProps, _numProps);
return retProps;
}
}
}
// We have to do this ArrayWithSize thing instead of
// separately providing the Array and a Count ... since they
// may not be in synch with multiple threads changing things
// We do not want to provide a copy of the array for each
// call for perf reasons. Besides this is used internally anyways.
internal virtual ArrayWithSize DynamicSinks
{
[System.Security.SecurityCritical] // auto-generated
get
{
if (_numProps == 0)
{
return null;
}
lock (this)
{
if (_sinks == null)
{
// Some property got unregistered -- we need to recreate
// the list of sinks.
_sinks = new IDynamicMessageSink[_numProps+GROW_BY];
for (int i=0; i<_numProps; i++)
{
_sinks[i] =
((IContributeDynamicSink)_props[i]).GetDynamicSink();
}
}
}
return new ArrayWithSize(_sinks, _numProps);
}
}
private static IDynamicMessageSink[] GrowDynamicSinksArray(IDynamicMessageSink[] sinks)
{
// grow the array
int newSize = (sinks != null ? sinks.Length : 0) + GROW_BY;
IDynamicMessageSink[] newSinks = new IDynamicMessageSink[newSize];
if (sinks != null)
{
// Copy existing properties over
// Initial size should be chosen so that this rarely happens
Array.Copy(sinks, newSinks, sinks.Length);
}
return newSinks;
}
[System.Security.SecurityCritical] // auto-generated
internal static void NotifyDynamicSinks(IMessage msg,
ArrayWithSize dynSinks, bool bCliSide, bool bStart, bool bAsync)
{
for (int i=0; i<dynSinks.Count; i++)
{
if (bStart == true)
{
dynSinks.Sinks[i].ProcessMessageStart(msg, bCliSide, bAsync);
}
else
{
dynSinks.Sinks[i].ProcessMessageFinish(msg, bCliSide, bAsync);
}
}
}
[System.Security.SecurityCritical] // auto-generated
internal static void CheckPropertyNameClash(String name, IDynamicProperty[] props, int count)
{
for (int i=0; i<count; i++)
{
if (props[i].Name.Equals(name))
{
throw new InvalidOperationException(
Environment.GetResourceString(
"InvalidOperation_DuplicatePropertyName"));
}
}
}
internal static IDynamicProperty[] GrowPropertiesArray(IDynamicProperty[] props)
{
// grow the array of IContextProperty objects
int newSize = (props != null ? props.Length : 0) + GROW_BY;
IDynamicProperty[] newProps = new IDynamicProperty[newSize];
if (props != null)
{
// Copy existing properties over.
Array.Copy(props, newProps, props.Length);
}
return newProps;
}
} //class DynamicPropertyHolder
// Used to return a reference to an array and the current fill size
// in cases where it is not thread safe to provide this info as two
// separate properties. This is for internal use only.
internal class ArrayWithSize
{
internal IDynamicMessageSink[] Sinks;
internal int Count;
internal ArrayWithSize(IDynamicMessageSink[] sinks, int count)
{
Sinks = sinks;
Count = count;
}
}
}

View File

@@ -0,0 +1,69 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** File: ComponentServices.cs
**
**
** Purpose: Defines the general purpose ComponentServices
**
**
===========================================================*/
namespace System.Runtime.Remoting.Services {
using System;
using System.Reflection;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Runtime.InteropServices;
//---------------------------------------------------------\\
//---------------------------------------------------------\\
// internal sealed class ComponentServices \\
//---------------------------------------------------------\\
//---------------------------------------------------------\\
[System.Security.SecurityCritical] // auto-generated_required
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class EnterpriseServicesHelper
{
[System.Security.SecurityCritical] // auto-generated_required
public static Object WrapIUnknownWithComObject(IntPtr punk)
{
return Marshal.InternalWrapIUnknownWithComObject(punk);
}
[System.Runtime.InteropServices.ComVisible(true)]
public static IConstructionReturnMessage CreateConstructionReturnMessage(IConstructionCallMessage ctorMsg, MarshalByRefObject retObj)
{
IConstructionReturnMessage ctorRetMsg = null;
// Create the return message
ctorRetMsg = new ConstructorReturnMessage(retObj, null, 0, null, ctorMsg);
// NOTE: WE ALLOW ONLY DEFAULT CTORs on SERVICEDCOMPONENTS
return ctorRetMsg;
}
[System.Security.SecurityCritical] // auto-generated_required
public static void SwitchWrappers(RealProxy oldcp, RealProxy newcp)
{
Object oldtp = oldcp.GetTransparentProxy();
Object newtp = newcp.GetTransparentProxy();
IntPtr oldcontextId = RemotingServices.GetServerContextForProxy(oldtp);
IntPtr newcontextId = RemotingServices.GetServerContextForProxy(newtp);
// switch the CCW from oldtp to new tp
Marshal.InternalSwitchCCW(oldtp, newtp);
}
};
}

View File

@@ -0,0 +1,48 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** File: Header.cs
**
**
** Purpose: Defines the out-of-band data for a call
**
**
**
===========================================================*/
namespace System.Runtime.Remoting.Messaging{
using System.Runtime.Remoting;
using System;
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class Header
{
public Header (String _Name, Object _Value)
: this(_Name, _Value, true) {
}
public Header (String _Name, Object _Value, bool _MustUnderstand)
{
Name = _Name;
Value = _Value;
MustUnderstand = _MustUnderstand;
}
public Header (String _Name, Object _Value, bool _MustUnderstand, String _HeaderNamespace)
{
Name = _Name;
Value = _Value;
MustUnderstand = _MustUnderstand;
HeaderNamespace = _HeaderNamespace;
}
public String Name;
public Object Value;
public bool MustUnderstand;
public String HeaderNamespace;
}
}

View File

@@ -0,0 +1,21 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: HeaderHandler
**
**
** Purpose: The delegate used to process headers on the stream
** during deserialization.
**
**
===========================================================*/
namespace System.Runtime.Remoting.Messaging {
using System.Runtime.Remoting;
//Define the required delegate
[System.Runtime.InteropServices.ComVisible(true)]
public delegate Object HeaderHandler(Header[] headers);
}

View File

@@ -0,0 +1,96 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** File: IActivator.cs
**
**
** Purpose: Defines the interface provided by activation services
**
**
**
===========================================================*/
namespace System.Runtime.Remoting.Activation {
using System;
using System.Runtime.Remoting.Messaging;
using System.Collections;
using System.Security.Permissions;
[System.Runtime.InteropServices.ComVisible(true)]
public interface IActivator
{
// return the next activator in the chain
IActivator NextActivator
{
[System.Security.SecurityCritical] // auto-generated_required
get;
[System.Security.SecurityCritical] // auto-generated_required
set;
}
// New method for activators.
[System.Security.SecurityCritical] // auto-generated_required
IConstructionReturnMessage Activate(IConstructionCallMessage msg);
// Returns the level at which this activator is active ..
// Should return one of the ActivatorLevels below
ActivatorLevel Level
{
[System.Security.SecurityCritical] // auto-generated_required
get;
}
}
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum ActivatorLevel
{
Construction = 4,
Context = 8,
AppDomain = 12,
Process = 16,
Machine = 20
}
[System.Runtime.InteropServices.ComVisible(true)]
public interface IConstructionCallMessage : IMethodCallMessage
{
IActivator Activator
{
[System.Security.SecurityCritical] // auto-generated_required
get;
[System.Security.SecurityCritical] // auto-generated_required
set;
}
Object[] CallSiteActivationAttributes
{
[System.Security.SecurityCritical] // auto-generated_required
get;
}
String ActivationTypeName
{
[System.Security.SecurityCritical] // auto-generated_required
get;
}
Type ActivationType
{
[System.Security.SecurityCritical] // auto-generated_required
get;
}
IList ContextProperties
{
[System.Security.SecurityCritical] // auto-generated_required
get;
}
}
[System.Runtime.InteropServices.ComVisible(true)]
public interface IConstructionReturnMessage : IMethodReturnMessage
{
}
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More