We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- namespace System.Runtime.Remoting.Contexts
- {
-
- using System;
- using System.Threading;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using System.Runtime.Remoting.Activation;
- using System.Security.Permissions;
-
- /// <internalonly/>
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class ContextProperty
- {
- internal string _name;
-
- internal object _property;
-
- /// <internalonly/>
- public virtual string Name {
- get { return _name; }
- }
-
- /// <internalonly/>
- public virtual object Property {
- get { return _property; }
- }
-
-
- internal ContextProperty(string name, object prop)
- {
- _name = name;
- _property = prop;
- }
- }
-
-
-
-
- /// <internalonly/>
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IContextAttribute
- {
- /// <internalonly/>
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- bool IsContextOK(Context ctx, IConstructionCallMessage msg);
- /// <internalonly/>
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void GetPropertiesForNewContext(IConstructionCallMessage msg);
- }
-
-
-
-
- /// <internalonly/>
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IContextProperty
- {
- /// <internalonly/>
-
-
- string Name {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
- /// <internalonly/>
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- bool IsNewContextOK(Context newCtx);
- /// <internalonly/>
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void Freeze(Context newContext);
- }
-
- /// <internalonly/>
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IContextPropertyActivator
- {
- /// <internalonly/>
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- bool IsOKToActivate(IConstructionCallMessage msg);
- /// <internalonly/>
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void CollectFromClientContext(IConstructionCallMessage msg);
- /// <internalonly/>
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- bool DeliverClientContextToServerContext(IConstructionCallMessage msg);
- /// <internalonly/>
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void CollectFromServerContext(IConstructionReturnMessage msg);
- /// <internalonly/>
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- bool DeliverServerContextToClientContext(IConstructionReturnMessage msg);
- }
-
-
-
-
-
-
-
- /// <internalonly/>
- [AttributeUsage(AttributeTargets.Class), Serializable()]
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class ContextAttribute : Attribute, IContextAttribute, IContextProperty
- {
- /// <internalonly/>
- protected string AttributeName;
-
-
- /// <internalonly/>
- public ContextAttribute(string name)
- {
- AttributeName = name;
- }
-
-
-
- /// <internalonly/>
- public virtual string Name {
- get { return AttributeName; }
- }
-
-
- /// <internalonly/>
- public virtual bool IsNewContextOK(Context newCtx)
- {
-
-
- return true;
- }
-
-
-
- /// <internalonly/>
- public virtual void Freeze(Context newContext)
- {
- BCLDebug.Log("ContextAttribute::ContextProperty::Freeze" + " for context " + newContext);
- }
-
-
-
- /// <internalonly/>
- public override bool Equals(object o)
- {
- IContextProperty prop = o as IContextProperty;
- return (null != prop) && AttributeName.Equals(prop.Name);
- }
-
- /// <internalonly/>
- public override int GetHashCode()
- {
- return this.AttributeName.GetHashCode();
- }
-
-
-
-
- /// <internalonly/>
- public virtual bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg)
- {
- if (ctx == null)
- throw new ArgumentNullException("ctx");
- if (ctorMsg == null)
- throw new ArgumentNullException("ctorMsg");
-
- BCLDebug.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;
- }
-
-
-
-
- /// <internalonly/>
- public virtual void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
- {
- if (ctorMsg == null)
- throw new ArgumentNullException("ctorMsg");
- ctorMsg.ContextProperties.Add((IContextProperty)this);
- }
- }
-
-
- }