Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,163 @@
2010-03-16 Jb Evain <jbevain@novell.com>
* Context.cs: use MOONLIGHT symbol to disambiguate
MonoTouch and Moonlight code.
2009-10-07 Sebastien Pouliot <sebastien@ximian.com>
* Context.cs: Remove LocalDataStoreSlot-related methods from
Moonlight build
2008-07-02 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* IDynamicMessageSink.cs
* IContextProperty.cs: Fix parameter names
* ContextAttribute.cs: Fix parameter names, exception names
2007-08-15 Atsushi Enomoto <atsushi@ximian.com>
* SynchronizationAttribute.cs : [ComVisible]
Tue Jan 23 17:48:42 CET 2007 Paolo Molaro <lupus@ximian.com>
* Context.cs: mark the GC-tracked field with UIntPtr.
Wed Mar 15 16:35:13 CET 2006 Paolo Molaro <lupus@ximian.com>
* Context.cs: update for LocalDataStoreSlot changes.
2006-01-31 Lluis Sanchez Gual <lluis@novell.com>
* Context.cs: Fixed double check lock.
2005-12-08 Sebastien Pouliot <sebastien@ximian.com>
* Context.cs: ContextProperties property is virtual.
* CrossContextDelegate.cs: Removed [Serializable] from 2.0 build.
* SynchronizationAttribute.cs: Fixed serialization to be compatible
with MS FX. Removed old TODO.
2005-05-09 Lluis Sanchez Gual <lluis@novell.com>
* SynchronizationAttribute.cs: Make it serializable. Fixes bug #60228.
2005-05-06 Lluis Sanchez Gual <lluis@novell.com>
* Context.cs: Fix unsafe double-check locks.
2005-05-02 Zoltan Varga <vargaz@freemail.hu>
* Context.cs: Remove process_id field to sync with the unmanaged
structure.
2004-10-26 Lluis Sanchez Gual <lluis@novell.com>
* Context.cs: Added NeedsContextSink property, which returns TRUE if
the current context has sinks that need to be executed when switching to
another context.
2004-09-22 Lluis Sanchez Gual <lluis@novell.com>
* Context.cs: In CreateServerObjectSinkChain, added a parameter to
specify that messages must be dispatched to the target object using
InternalExecute. Usually if the target is a proxy, the sink uses
RealProxy.Invoke to dispatch the method. This can't be done for local
CBOs since we would loop for ever.
2004-06-15 Gert Driesen <drieseng@users.sourceforge.net>
* SynchronizationAttribute.cs: added TODO for serialization
2004-06-09 Gert Driesen <drieseng@users.sourceforge.net>
* Context.cs: Added finalizer to match MS.NET
2003-12-23 Lluis Sanchez Gual <lluis@ximian.com>
* SynchronizationAttribute.cs: Several bug fixes.
2003-11-21 Lluis Sanchez Gual <lluis@ximian.com>
* Context.cs: Added internal static_data field.
2003-11-19 Lluis Sanchez Gual <lluis@ximian.com>
* Context.cs: Implemented several missing methods and properties:
ContextProperties, DoCallBack, AllocateDataSlot, AllocateNamedDataSlot,
FreeNamedDataSlot, GetData, GetNamedDataSlot, SetData.
* SynchronizationAttribute.cs: Fixed check for current context.
2003-11-18 Lluis Sanchez Gual <lluis@ximian.com>
* SynchronizationAttribute.cs: Implemented.
2003-11-14 Miguel de Icaza <miguel@ximian.com>
* ContextProperty.cs: Add implementaion bits.
2003-07-28 Duncan Mak <duncan@ximian.com>
* ContextAttribute.cs: Removed constructor.
2003-04-03 Lluis Sanchez Gual <lluis@ideary.com>
* CrossContextChannel.cs: Improved support for OneWay and Async messages.
2003-03-20 Lluis Sanchez Gual <lluis@ideary.com>
* Context.cs: Implemented support for dynamic properties and dynamic message sinks.
* CrossContextChannel.cs: Added support for dynamic message sinks.
2003-03-03 Lluis Sanchez Gual <lluis@ideary.com>
* Context.cs : Management of the default context moved to the runtime.
Implemented creation of the client context, server context, object and envoy sinks.
Added method for creating a new context.
* CrossContextChannel.cs : Removed check for construction messages. Now construction
go through the IActivators.
2003-02-18 Lluis Sanchez Gual <lluis@ideary.com>
* Contexts.cs : Added methods for getting the client context sink chain and the
envoy sink chain. Also added stub methods for context switch and creation.
* CrossContextChannel.cs : Added.
2003-02-03 Patrik Torstensson
* Contexts.cs : Changed order of fields to match the runtime implementation.
2003-01-29 Lluis Sanchez Gual <lluis@ideary.com>
* Context.cs: Object sinks must be created for each object
(they can contain object-specific info).
2002-12-20 Lluis Sanchez Gual <lluis@ideary.com>
* Context.cs: Added creation of default server context and
object context sinks.
2002-07-31 Duncan Mak <duncan@ximian.com>
* SynchronizationAttribute.cs: Added more interfaces, it
implements them (via CorCompare), but they're not listed in the docs.
* ContextProperty.cs:
* CrossContextDelegate.cs: Added to CVS.
* ContextAttribute.cs: Added missing constructor.
2002-07-29 Duncan Mak <duncan@ximian.com>
* IContributeServerContentSink.cs: Removed.
* IContributeServerContextSink.cs: Replaces IContributeServerContentSink.
2002-07-24 Duncan Mak <duncan@ximian.com>
* SynchronizationAttribute.cs: Added missing attributes.
* IContextPropertyActivator.cs:
* IContributeClientContextSink.cs:
* IContributeDynamicSink.cs:
* IContributeEnvoySink.cs:
* IContributeObjectSink.cs:
* IContributeServerContentSink.cs: Added the missing interfaces.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,125 @@
//
// System.Runtime.Remoting.Contexts.ContextAttribute.cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.Remoting.Activation;
using System.Collections;
namespace System.Runtime.Remoting.Contexts {
[AttributeUsage (AttributeTargets.Class)]
[Serializable]
[System.Runtime.InteropServices.ComVisible (true)]
public class ContextAttribute : Attribute, IContextAttribute, IContextProperty {
protected string AttributeName;
public ContextAttribute (string name)
{
AttributeName = name;
}
public virtual string Name {
get {
return AttributeName;
}
}
public override bool Equals (object o)
{
if (o == null)
return false;
if (!(o is ContextAttribute))
return false;
ContextAttribute ca = (ContextAttribute) o;
if (ca.AttributeName != AttributeName)
return false;
return true;
}
public virtual void Freeze (Context newContext)
{
}
public override int GetHashCode ()
{
if (AttributeName == null)
return 0;
return AttributeName.GetHashCode ();
}
/// <summary>
/// Adds the current context property to the IConstructionCallMessage
/// </summary>
public virtual void GetPropertiesForNewContext (IConstructionCallMessage ctorMsg)
{
if (ctorMsg == null)
throw new ArgumentNullException ("ctorMsg");
IList list = ctorMsg.ContextProperties;
list.Add (this);
}
// <summary>
// True whether the context arguments satisfies the requirements
// of the current context.
// </summary>
public virtual bool IsContextOK (Context ctx, IConstructionCallMessage ctorMsg)
{
if (ctorMsg == null)
throw new ArgumentNullException ("ctorMsg");
if (ctx == null)
throw new ArgumentNullException ("ctx");
if (!ctorMsg.ActivationType.IsContextful)
return true;
IContextProperty p = ctx.GetProperty (AttributeName);
if (p == null)
return false;
if (this != p)
return false;
return true;
}
public virtual bool IsNewContextOK (Context newCtx)
{
return true;
}
}
}

View File

@@ -0,0 +1,56 @@
//
// System.Runtime.Remoting.Contexts.ContextProperty..cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public class ContextProperty
{
string name;
object prop;
private ContextProperty (string name, object prop)
{
this.name = name;
this.prop = prop;
}
public virtual string Name {
get { return name; }
}
public virtual object Property {
get { return prop; }
}
}
}

View File

@@ -0,0 +1,161 @@
//
// System.Runtime.Remoting.Contexts.CrossContextChannel.cs
//
// Author: Lluis Sanchez Gual (lluis@ideary.com)
//
// (C) 2002, Lluis Sanchez Gual
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Threading;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Channels;
namespace System.Runtime.Remoting.Contexts
{
internal class CrossContextChannel: IMessageSink
{
public IMessage SyncProcessMessage (IMessage msg)
{
ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (msg);
Context oldContext = null;
IMessage response;
if (Threading.Thread.CurrentContext != identity.Context)
oldContext = Context.SwitchToContext (identity.Context);
try
{
Context.NotifyGlobalDynamicSinks (true, msg, false, false);
Thread.CurrentContext.NotifyDynamicSinks (true, msg, false, false);
response = identity.Context.GetServerContextSinkChain().SyncProcessMessage (msg);
Context.NotifyGlobalDynamicSinks (false, msg, false, false);
Thread.CurrentContext.NotifyDynamicSinks (false, msg, false, false);
}
catch (Exception ex)
{
response = new ReturnMessage (ex, (IMethodCallMessage)msg);
}
finally
{
if (oldContext != null)
Context.SwitchToContext (oldContext);
}
return response;
}
public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
{
ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (msg);
Context oldContext = null;
if (Threading.Thread.CurrentContext != identity.Context)
oldContext = Context.SwitchToContext (identity.Context);
try
{
Context.NotifyGlobalDynamicSinks (true, msg, false, true);
Thread.CurrentContext.NotifyDynamicSinks (true, msg, false, false);
if (replySink != null) replySink = new ContextRestoreSink (replySink, oldContext, msg);
IMessageCtrl res = identity.AsyncObjectProcessMessage (msg, replySink);
if (replySink == null)
{
Context.NotifyGlobalDynamicSinks (false, msg, false, false);
Thread.CurrentContext.NotifyDynamicSinks (false, msg, false, false);
}
return res;
}
catch (Exception ex)
{
if (replySink != null)
replySink.SyncProcessMessage (new ReturnMessage (ex, (IMethodCallMessage)msg));
return null;
}
finally
{
if (oldContext != null)
Context.SwitchToContext (oldContext);
}
}
public IMessageSink NextSink
{
get { return null; }
}
class ContextRestoreSink: IMessageSink
{
IMessageSink _next;
Context _context;
IMessage _call;
public ContextRestoreSink (IMessageSink next, Context context, IMessage call)
{
_next = next;
_context = context;
_call = call;
}
public IMessage SyncProcessMessage (IMessage msg)
{
try
{
Context.NotifyGlobalDynamicSinks (false, msg, false, false);
Thread.CurrentContext.NotifyDynamicSinks (false, msg, false, false);
return _next.SyncProcessMessage (msg);
}
catch (Exception ex)
{
return new ReturnMessage (ex, (IMethodCallMessage)_call);
}
finally
{
if (_context != null)
Context.SwitchToContext (_context);
}
}
public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
{
throw new NotSupportedException(); // Not needed
}
public IMessageSink NextSink
{
get { return _next; }
}
}
}
}

View File

@@ -0,0 +1,33 @@
//
// System.Runtime.Remoting.Contexts.CrossContextDelegate.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public delegate void CrossContextDelegate ();
}

View File

@@ -0,0 +1,44 @@
//
// System.Runtime.Remoting.Contexts.IContextAttribute..cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.Remoting.Activation;
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IContextAttribute {
void GetPropertiesForNewContext (IConstructionCallMessage msg);
bool IsContextOK (Context ctx, IConstructionCallMessage msg);
}
}

View File

@@ -0,0 +1,47 @@
//
// System.Runtime.Remoting.Contexts.IContextProperty.cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IContextProperty {
string Name {
get;
}
void Freeze (Context newContext);
bool IsNewContextOK (Context newCtx);
}
}

View File

@@ -0,0 +1,45 @@
//
// System.Runtime.Remoting.Contexts.IContextPropertyActivator..cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.Remoting.Activation;
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IContextPropertyActivator
{
void CollectFromClientContext (IConstructionCallMessage msg);
void CollectFromServerContext (IConstructionReturnMessage msg);
bool DeliverClientContextToServerContext (IConstructionCallMessage msg);
bool DeliverServerContextToClientContext (IConstructionReturnMessage msg);
bool IsOKToActivate (IConstructionCallMessage msg);
}
}

View File

@@ -0,0 +1,41 @@
//
// System.Runtime.Remoting.Contexts.IContributeClientContextSink.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Copyright. Ximian, Inc.
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IContributeClientContextSink
{
IMessageSink GetClientContextSink (IMessageSink nextSink);
}
}

View File

@@ -0,0 +1,41 @@
//
// System.Runtime.Remoting.Contexts.IContributeDynamicSink.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Copyright. Ximian, Inc.
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.Remoting.Contexts;
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IContributeDynamicSink
{
IDynamicMessageSink GetDynamicSink ();
}
}

View File

@@ -0,0 +1,42 @@
//
// System.Runtime.Remoting.Contexts.IContributeEnvoySink.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Copyright. Ximian, Inc.
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IContributeEnvoySink
{
IMessageSink GetEnvoySink (MarshalByRefObject obj, IMessageSink nextSink);
}
}

View File

@@ -0,0 +1,42 @@
//
// System.Runtime.Remoting.Contexts.IContributeObjectSink.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IContributeObjectSink
{
IMessageSink GetObjectSink (MarshalByRefObject obj, IMessageSink nextSink);
}
}

View File

@@ -0,0 +1,42 @@
//
// System.Runtime.Remoting.Contexts.IContributeServerContextSink.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IContributeServerContextSink
{
IMessageSink GetServerContextSink (IMessageSink nextSink);
}
}

View File

@@ -0,0 +1,44 @@
//
// System.Runtime.Remoting.Contexts.IDynamicMessageSink.cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IDynamicMessageSink {
void ProcessMessageFinish (IMessage replyMsg, bool bCliSide, bool bAsync);
void ProcessMessageStart (IMessage reqMsg, bool bCliSide, bool bAsync);
}
}

View File

@@ -0,0 +1,43 @@
//
// System.Runtime.Remoting.Contexts.IDynamicProperty..cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Runtime.Remoting.Contexts {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IDynamicProperty {
string Name {
get;
}
}
}

View File

@@ -0,0 +1,318 @@
//
// System.Runtime.Remoting.Contexts.SynchronizationAttribute.cs
//
// Author:
// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) Novell, Inc. http://www.ximian.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Threading;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Activation;
namespace System.Runtime.Remoting.Contexts
{
[AttributeUsage(AttributeTargets.Class)]
[Serializable]
[System.Runtime.InteropServices.ComVisible (true)]
public class SynchronizationAttribute: ContextAttribute, IContributeClientContextSink, IContributeServerContextSink
{
public const int NOT_SUPPORTED = 1;
public const int SUPPORTED = 2;
public const int REQUIRED = 4;
public const int REQUIRES_NEW = 8;
bool _bReEntrant;
int _flavor;
[NonSerialized]
bool _locked;
[NonSerialized]
int _lockCount;
[NonSerialized]
Mutex _mutex = new Mutex (false);
[NonSerialized]
Thread _ownerThread;
public SynchronizationAttribute ()
: this (REQUIRES_NEW, false)
{
}
public SynchronizationAttribute (bool reEntrant)
: this (REQUIRES_NEW, reEntrant)
{
}
public SynchronizationAttribute (int flag)
: this (flag, false)
{
}
public SynchronizationAttribute (int flag, bool reEntrant)
: base ("Synchronization")
{
if (flag != NOT_SUPPORTED && flag != REQUIRED && flag != REQUIRES_NEW && flag != SUPPORTED)
throw new ArgumentException ("flag");
_bReEntrant = reEntrant;
_flavor = flag;
}
public virtual bool IsReEntrant
{
get { return _bReEntrant; }
}
public virtual bool Locked
{
get
{
return _locked;
}
set
{
if (value)
{
_mutex.WaitOne ();
lock (this)
{
_lockCount++;
if (_lockCount > 1)
ReleaseLock (); // Thread already had the lock
_ownerThread = Thread.CurrentThread;
}
}
else
{
lock (this)
{
while (_lockCount > 0 && _ownerThread == Thread.CurrentThread)
{
_lockCount--;
_mutex.ReleaseMutex ();
_ownerThread = null;
}
}
}
}
}
internal void AcquireLock ()
{
_mutex.WaitOne ();
lock (this)
{
_ownerThread = Thread.CurrentThread;
_lockCount++;
}
}
internal void ReleaseLock ()
{
lock (this)
{
if (_lockCount > 0 && _ownerThread == Thread.CurrentThread) {
_lockCount--;
_mutex.ReleaseMutex ();
_ownerThread = null;
}
}
}
[System.Runtime.InteropServices.ComVisible (true)]
public override void GetPropertiesForNewContext (IConstructionCallMessage ctorMsg)
{
if (_flavor != NOT_SUPPORTED) {
ctorMsg.ContextProperties.Add (this);
}
}
public virtual IMessageSink GetClientContextSink (IMessageSink nextSink)
{
return new SynchronizedClientContextSink (nextSink, this);
}
public virtual IMessageSink GetServerContextSink (IMessageSink nextSink)
{
return new SynchronizedServerContextSink (nextSink, this);
}
[System.Runtime.InteropServices.ComVisible (true)]
public override bool IsContextOK (Context ctx, IConstructionCallMessage msg)
{
SynchronizationAttribute prop = ctx.GetProperty ("Synchronization") as SynchronizationAttribute;
switch (_flavor)
{
case NOT_SUPPORTED: return (prop == null);
case REQUIRED: return (prop != null);
case REQUIRES_NEW: return false;
case SUPPORTED: return true;
}
return false;
}
internal static void ExitContext ()
{
if (Thread.CurrentContext.IsDefaultContext) return;
SynchronizationAttribute prop = Thread.CurrentContext.GetProperty ("Synchronization") as SynchronizationAttribute;
if (prop == null) return;
prop.Locked = false;
}
internal static void EnterContext ()
{
if (Thread.CurrentContext.IsDefaultContext) return;
SynchronizationAttribute prop = Thread.CurrentContext.GetProperty ("Synchronization") as SynchronizationAttribute;
if (prop == null) return;
prop.Locked = true;
}
}
internal class SynchronizedClientContextSink: IMessageSink
{
IMessageSink _next;
SynchronizationAttribute _att;
public SynchronizedClientContextSink (IMessageSink next, SynchronizationAttribute att)
{
_att = att;
_next = next;
}
public IMessageSink NextSink
{
get { return _next; }
}
public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
{
if (_att.IsReEntrant)
{
_att.ReleaseLock(); // Unlock when leaving the context
replySink = new SynchronizedContextReplySink (replySink, _att, true);
}
return _next.AsyncProcessMessage (msg, replySink);
}
public IMessage SyncProcessMessage (IMessage msg)
{
if (_att.IsReEntrant)
_att.ReleaseLock (); // Unlock when leaving the context
try
{
return _next.SyncProcessMessage (msg);
}
finally
{
if (_att.IsReEntrant)
_att.AcquireLock ();
}
}
}
internal class SynchronizedServerContextSink: IMessageSink
{
IMessageSink _next;
SynchronizationAttribute _att;
public SynchronizedServerContextSink (IMessageSink next, SynchronizationAttribute att)
{
_att = att;
_next = next;
}
public IMessageSink NextSink
{
get { return _next; }
}
public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
{
_att.AcquireLock ();
replySink = new SynchronizedContextReplySink (replySink, _att, false);
return _next.AsyncProcessMessage (msg, replySink);
}
public IMessage SyncProcessMessage (IMessage msg)
{
_att.AcquireLock ();
try
{
return _next.SyncProcessMessage (msg);
}
finally
{
_att.ReleaseLock ();
}
}
}
internal class SynchronizedContextReplySink: IMessageSink
{
IMessageSink _next;
bool _newLock;
SynchronizationAttribute _att;
public SynchronizedContextReplySink (IMessageSink next, SynchronizationAttribute att, bool newLock)
{
_newLock = newLock;
_next = next;
_att = att;
}
public IMessageSink NextSink
{
get { return _next; }
}
public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
{
// Never called
throw new NotSupportedException ();
}
public IMessage SyncProcessMessage (IMessage msg)
{
if (_newLock) _att.AcquireLock ();
else _att.ReleaseLock ();
try
{
return _next.SyncProcessMessage (msg);
}
finally
{
if (_newLock)
_att.ReleaseLock ();
}
}
}
}