private GetProperty ( String name ) : IContextProperty | ||
name | String | |
return | IContextProperty |
// Determine if a context is OK with respect to this attribute. public override bool IsContextOK (Context ctx, IConstructionCallMessage msg) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (msg == null) { throw new ArgumentNullException("msg"); } if (flag == NOT_SUPPORTED) { if (ctx.GetProperty("Synchronization") != null) { return(false); } } else if (flag == REQUIRED) { Object prop = ctx.GetProperty("Synchronization"); if (prop == null) { return(false); } savedProp = prop; } else if (flag != REQUIRES_NEW) { return(true); } return(false); }
// IContextAttribute::IsContextOK // Default calls Object::Equals on the property and does not // bother with the ctorMsg. /// <include file='doc\ContextProperty.uex' path='docs/doc[@for="ContextAttribute.IsContextOK"]/*' /> /// <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); }
// <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 override bool IsContextOK(Context ctx, IConstructionCallMessage msg) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (msg == null) { throw new ArgumentNullException("msg"); } bool flag = true; if (this._flavor == 8) { return(false); } SynchronizationAttribute property = (SynchronizationAttribute)ctx.GetProperty("Synchronization"); if (((this._flavor == 1) && (property != null)) || ((this._flavor == 4) && (property == null))) { flag = false; } if (this._flavor == 4) { this._cliCtxAttr = property; } return(flag); }
public override bool IsContextOK(Context ctx, System.Runtime.Remoting.Activation.IConstructionCallMessage ctorMsg) { InterceptProperty p = ctx.GetProperty("Intercept") as InterceptProperty; if (p == null) return false; return true; }
internal static Context CreateNewContext(IConstructionCallMessage msg) { // Create the new context Context newContext = new Context(); foreach (IContextProperty prop in msg.ContextProperties) { if (newContext.GetProperty(prop.Name) == null) { newContext.SetProperty(prop); } } newContext.Freeze(); // Ask each context property whether the new context is OK foreach (IContextProperty prop in msg.ContextProperties) { if (!prop.IsNewContextOK(newContext)) { throw new RemotingException("A context property did not approve the candidate context for activating the object"); } } return(newContext); }
public bool IsNewContextOK(Context newCtx) { InterceptProperty p = newCtx.GetProperty("Intercept") as InterceptProperty; if(p == null) return false; return true; }
public bool IsNewContextOK(Context newCtx) { var p = newCtx.GetProperty("Reporting") as ReportingProperty; if (p == null) return false; return true; }
/// <summary> /// permet de vérifier que le context est ok apres son initialisation /// </summary> /// <param name="newCtx">le context qui vient d'etre créé</param> /// <returns>True : le contexte contient bien une propriété appelé "ValidationData". False sinon.</returns> public bool IsNewContextOK(Context newCtx) { DataValidationProperty prop=newCtx.GetProperty("DataValidation") as DataValidationProperty; if (prop!=null) // on a une propriété appelé ValidationData dans le contexte ? return true; // Oui -> on accepte le contexte return false; // Non -> on refuse le contexte }
//Le runtime .NET interroge pour savoir si le contexte courant est valide. //Si cette fonction false, le runtime créé un nouveau contexte et appelle GetPropertiesForNewContext() // pour vérifier si le context est valid, on vérifie la présence (et la validité si besoin) d'un propriété public override bool IsContextOK(Context ctx,IConstructionCallMessage ctorMsg) { //return false; // Seulement si vous souhaitez un contexte par instance ! DataValidationProperty prop=ctx.GetProperty("DataValidation") as DataValidationProperty; if (prop!=null) // on a une propriété appelé ValidationData dans le contexte ? return true; // Oui -> on accepte le contexte return false; // Non -> on refuse le contexte }
public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg) { var p = ctx.GetProperty("Reporting") as ReportingProperty; if (p == null) { return false; } return true; }
public SynchRes CheckContext (Context ctx) { object otherp = ctx.GetProperty ("Synchronization"); object thisp = Thread.CurrentContext.GetProperty ("Synchronization"); if (thisp == null) return SynchRes.NoSync; if (thisp == otherp) return SynchRes.SameSync; return SynchRes.NewSync; }
public bool IsNewContextOK(Context ctx) { AOPProperty newContextLogProperty = ctx.GetProperty("AOP") as AOPProperty; if (newContextLogProperty == null) { Debug.Assert(false); return false; } return (true); }
public override bool IsContextOK(Context ctx, IConstructionCallMessage msg) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (msg == null) { throw new ArgumentNullException("msg"); } Contract.EndContractBlock(); // < bool isOK = true; if (_flavor == REQUIRES_NEW) { isOK = false; // Each activation request instantiates a new attribute class. // We are relying on that for the REQUIRES_NEW case! Contract.Assert(ctx.GetProperty(PROPERTY_NAME) != this, "ctx.GetProperty(PROPERTY_NAME) != this"); } else { SynchronizationAttribute syncProp = (SynchronizationAttribute)ctx.GetProperty(PROPERTY_NAME); if (((_flavor == NOT_SUPPORTED) && (syncProp != null)) || ((_flavor == REQUIRED) && (syncProp == null)) ) { isOK = false; } if (_flavor == REQUIRED) { // pick up the property from the current context _cliCtxAttr = syncProp; } } return(isOK); }
// Override ContextAttribute's implementation of IContextAttribute::IsContextOK /// <include file='doc\SynchronizedDispatch.uex' path='docs/doc[@for="SynchronizationAttribute.IsContextOK"]/*' /> public override bool IsContextOK(Context ctx, IConstructionCallMessage msg) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (msg == null) { throw new ArgumentNullException("msg"); } // FUTURE: we should also check for ThreadAffinity! // If the context has ThreadAffinity then it is synchronized by default! bool isOK = true; if (_flavor == REQUIRES_NEW) { isOK = false; // Each activation request instantiates a new attribute class. // We are relying on that for the REQUIRES_NEW case! BCLDebug.Assert(ctx.GetProperty(PROPERTY_NAME) != this, "ctx.GetProperty(PROPERTY_NAME) != this"); } else { SynchronizationAttribute syncProp = (SynchronizationAttribute)ctx.GetProperty(PROPERTY_NAME); if (((_flavor == NOT_SUPPORTED) && (syncProp != null)) || ((_flavor == REQUIRED) && (syncProp == null)) ) { isOK = false; } if (_flavor == REQUIRED) { // pick up the property from the current context _cliCtxAttr = syncProp; } } return(isOK); }
//Le runtime .NET interroge l'attribut pour savoir si le contexte courant est valide. //Si cette fonction renvoi false, le runtime créé un nouveau contexte et appelle GetPropertiesForNewContext() // pour vérifier si le context est valid, on vérifie la présence (et la validité si besoin) d'une propriété public override bool IsContextOK(Context ctx,IConstructionCallMessage ctorMsg) { //le return false permet de forcer systématiquement un nouveau contexte pour chaqueinstance // utilise si une instance d'un type créé des instance de ce meme type : vous pouvez intercepter // les appels entre instance d'un meme type ( car il y aura changement de contexte ) //return false; InterceptionAppelProperty prop=ctx.GetProperty("InterceptionAppelProperty") as InterceptionAppelProperty; if (prop!=null) // on a une propriété appelé InterceptionAppelProperty dans le contexte ? return true; // Oui -> on accepte le contexte return false; // Non -> on refuse le contexte }
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); }
public virtual bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (ctorMsg == null) { throw new ArgumentNullException("ctorMsg"); } if (!ctorMsg.ActivationType.IsContextful) { return(true); } object property = ctx.GetProperty(this.AttributeName); return((property != null) && this.Equals(property)); }
public override bool IsContextOK(Context ctx, IConstructionCallMessage msg) { SynchronizationAttribute synchronizationAttribute = ctx.GetProperty("Synchronization") as SynchronizationAttribute; switch (this._flavor) { case 1: return(synchronizationAttribute == null); case 2: return(true); case 4: return(synchronizationAttribute != null); case 8: return(false); } return(false); }
internal static Context CreateNewContext(IConstructionCallMessage msg) { Context context = new Context(); foreach (object obj in msg.ContextProperties) { IContextProperty contextProperty = (IContextProperty)obj; if (context.GetProperty(contextProperty.Name) == null) { context.SetProperty(contextProperty); } } context.Freeze(); foreach (object obj2 in msg.ContextProperties) { IContextProperty contextProperty2 = (IContextProperty)obj2; if (!contextProperty2.IsNewContextOK(context)) { throw new RemotingException("A context property did not approve the candidate context for activating the object"); } } return(context); }
// Determine if a context is OK with respect to this attribute. public override bool IsContextOK (Context ctx, IConstructionCallMessage msg) { if(ctx == null) { throw new ArgumentNullException("ctx"); } if(msg == null) { throw new ArgumentNullException("msg"); } if(flag == NOT_SUPPORTED) { if(ctx.GetProperty("Synchronization") != null) { return false; } } else if(flag == REQUIRED) { Object prop = ctx.GetProperty("Synchronization"); if(prop == null) { return false; } savedProp = prop; } else if(flag != REQUIRES_NEW) { return true; } return false; }
// This function is called by ActivationServices in case // the activation needs to be within the same appdomain. These // are only for ContextBound types. // It is also called to do satisfy remote incoming requests from // the activation services. These could be for both ContextBound // and MarshalByRef types. internal static IConstructionReturnMessage DoCrossContextActivation( IConstructionCallMessage reqMsg) { bool bCtxBound = reqMsg.ActivationType.IsContextful; ContextTransitionFrame frame = new ContextTransitionFrame(); if (bCtxBound) { // If the type is context bound, we need to create // the appropriate context and activate the object inside // it. // Create a new Context Context serverContext = new Context(); ArrayList list = (ArrayList) reqMsg.ContextProperties; Assembly asm = null; for (int i=0; i<list.Count; i++) { IContextProperty prop = list[i] as IContextProperty; if (null == prop) { throw new RemotingException( Environment.GetResourceString( "Remoting_Activation_BadAttribute")); } asm = prop.GetType().Assembly; // Make a security check to ensure that the context property // is from a trusted assembly! CheckForInfrastructurePermission(asm); // This ensures that we don't try to add duplicate // attributes (eg. type attributes common on both client // and server end) if (serverContext.GetProperty(prop.Name) == null) { serverContext.SetProperty(prop); } } // No more property changes to the server context from here. serverContext.Freeze(); // (This seems like an overkill but that is how it is spec-ed) // Ask each of the properties in the context we formed from // if it is happy with the current context. for (int i=0; i<list.Count;i++) { if (!((IContextProperty)list[i]).IsNewContextOK( serverContext)) { throw new RemotingException( Environment.GetResourceString( "Remoting_Activation_PropertyUnhappy")); } } // Change to server context Thread.CurrentThread.EnterContext(serverContext, ref frame); } // call the first sink in the server context chain IMethodReturnMessage retMsg = (IMethodReturnMessage) Thread.CurrentContext.GetServerContextChain().SyncProcessMessage(reqMsg); // The return message may not be of type // IConstructionReturnMessage if an exception happens // in the sink chains. Exception e = null; IConstructionReturnMessage replyMsg = retMsg as IConstructionReturnMessage; if (null == replyMsg) { if (retMsg != null) { e = retMsg.Exception; } else { e = new RemotingException( Environment.GetResourceString( "Remoting_Activation_Failed")); } replyMsg = new ConstructorReturnMessage(e,null); // We have created our own message ... transfer the callcontext // from the request message. ((ConstructorReturnMessage)replyMsg).SetLogicalCallContext( (LogicalCallContext) reqMsg.Properties[Message.CallContextKey]); } if (bCtxBound) { Thread.CurrentThread.ReturnToContext(ref frame); } return replyMsg; }
public override bool IsContextOK(Context ctx, IConstructionCallMessage msg) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (msg == null) { throw new ArgumentNullException("msg"); } bool flag = true; if (this._flavor == 8) { return false; } SynchronizationAttribute property = (SynchronizationAttribute) ctx.GetProperty("Synchronization"); if (((this._flavor == 1) && (property != null)) || ((this._flavor == 4) && (property == null))) { flag = false; } if (this._flavor == 4) { this._cliCtxAttr = property; } return flag; }
[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; }
public override bool IsNewContextOK(Context newCtx) { try { InterceptProperty p = newCtx.GetProperty("Intercept") as InterceptProperty; if (p == null) return false; return true; } catch (Exception e) { SeleniumLog log = SeleniumLog.Instance(); log.Warning().WriteLine("SeleniumLog Exception: 01-09 - " + e.Message); return false; } }
public override bool IsContextOK(Context ctx, System.Runtime.Remoting.Activation.IConstructionCallMessage ctorMsg) { try { InterceptProperty p = ctx.GetProperty("Intercept") as InterceptProperty; if (p == null) return false; return true; } catch (Exception e) { SeleniumLog log = SeleniumLog.Instance(); log.Warning().WriteLine("SeleniumLog Exception: 01-08 - " + e.Message); return false; } }
// Determine if a context is OK with respect to this attribute. public virtual bool IsContextOK (Context ctx, IConstructionCallMessage ctorMsg) { if(ctx == null) { throw new ArgumentNullException("ctx"); } if(ctorMsg == null) { throw new ArgumentNullException("ctorMsg"); } if(!ctorMsg.ActivationType.IsContextful) { return true; } Object value = ctx.GetProperty(AttributeName); return (value != null && this.Equals(value)); }
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 IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg) { bool isContextful = reqMsg.ActivationType.IsContextful; Context newCtx = null; if (isContextful) { newCtx = new Context(); ArrayList contextProperties = (ArrayList) reqMsg.ContextProperties; RuntimeAssembly asm = null; for (int i = 0; i < contextProperties.Count; i++) { IContextProperty prop = contextProperties[i] as IContextProperty; if (prop == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } asm = (RuntimeAssembly) prop.GetType().Assembly; CheckForInfrastructurePermission(asm); if (newCtx.GetProperty(prop.Name) == null) { newCtx.SetProperty(prop); } } newCtx.Freeze(); for (int j = 0; j < contextProperties.Count; j++) { if (!((IContextProperty) contextProperties[j]).IsNewContextOK(newCtx)) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy")); } } } InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback); object[] args = new object[] { reqMsg }; if (isContextful) { return (Thread.CurrentThread.InternalCrossContextCallback(newCtx, ftnToCall, args) as IConstructionReturnMessage); } return (ftnToCall(args) as IConstructionReturnMessage); }
public bool IsNewContextOK(Context newCtx) { var p = newCtx.GetProperty("Intercept") as InterceptProperty; return p != null; }
[System.Security.SecurityCritical] // auto-generated internal static IConstructionReturnMessage DoCrossContextActivation( IConstructionCallMessage reqMsg) { bool bCtxBound = reqMsg.ActivationType.IsContextful; Context serverContext = null; if (bCtxBound) { // If the type is context bound, we need to create // the appropriate context and activate the object inside // it. // < // Create a new Context serverContext = new Context(); // < ArrayList list = (ArrayList) reqMsg.ContextProperties; RuntimeAssembly asm = null; for (int i=0; i<list.Count; i++) { IContextProperty prop = list[i] as IContextProperty; if (null == prop) { throw new RemotingException( Environment.GetResourceString( "Remoting_Activation_BadAttribute")); } asm = (RuntimeAssembly)prop.GetType().Assembly; // Make a security check to ensure that the context property // is from a trusted assembly! CheckForInfrastructurePermission(asm); // This ensures that we don't try to add duplicate // attributes (eg. type attributes common on both client // and server end) if (serverContext.GetProperty(prop.Name) == null) { serverContext.SetProperty(prop); } } // No more property changes to the server context from here. serverContext.Freeze(); // (This seems like an overkill but that is how it is spec-ed) // Ask each of the properties in the context we formed from // if it is happy with the current context. for (int i=0; i<list.Count;i++) { if (!((IContextProperty)list[i]).IsNewContextOK( serverContext)) { throw new RemotingException( Environment.GetResourceString( "Remoting_Activation_PropertyUnhappy")); } } } IConstructionReturnMessage replyMsg; InternalCrossContextDelegate xctxDel = new InternalCrossContextDelegate(DoCrossContextActivationCallback); Object[] args = new Object[] { reqMsg }; if (bCtxBound) { replyMsg = Thread.CurrentThread.InternalCrossContextCallback( serverContext, xctxDel, args) as IConstructionReturnMessage; } else { replyMsg = xctxDel(args) as IConstructionReturnMessage; } return replyMsg; }
public override bool IsContextOK(Context ctx, IConstructionCallMessage msg) { if (ctx == null) throw new ArgumentNullException("ctx"); if (msg == null) throw new ArgumentNullException("msg"); Contract.EndContractBlock(); // < bool isOK = true; if (_flavor == REQUIRES_NEW) { isOK = false; // Each activation request instantiates a new attribute class. // We are relying on that for the REQUIRES_NEW case! Contract.Assert(ctx.GetProperty(PROPERTY_NAME) != this, "ctx.GetProperty(PROPERTY_NAME) != this"); } else { SynchronizationAttribute syncProp = (SynchronizationAttribute) ctx.GetProperty(PROPERTY_NAME); if ( ( (_flavor == NOT_SUPPORTED)&&(syncProp != null) ) || ( (_flavor == REQUIRED)&&(syncProp == null) ) ) { isOK = false; } if (_flavor == REQUIRED) { // pick up the property from the current context _cliCtxAttr = syncProp; } } return isOK; }
public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg) { var p = (InterceptProperty)ctx.GetProperty("Intercept"); return p != null; }
public override bool IsContextOK(Context ctx, IConstructionCallMessage msg) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (msg == null) { throw new ArgumentNullException("msg"); } bool result = true; if (this._flavor == 8) { result = false; } else { SynchronizationAttribute synchronizationAttribute = (SynchronizationAttribute)ctx.GetProperty("Synchronization"); if ((this._flavor == 1 && synchronizationAttribute != null) || (this._flavor == 4 && synchronizationAttribute == null)) { result = false; } if (this._flavor == 4) { this._cliCtxAttr = synchronizationAttribute; } } return(result); }
public bool IsNewContextOK(Context newCtx) { var p = newCtx.GetProperty(this.Name) as InterceptionProperty; return p != null; }
public override bool IsNewContextOK(Context newCtx) { var p = (InterceptProperty)newCtx.GetProperty("Intercept"); return p != null; }
/// <summary> /// check context /// </summary> /// <param name="context"></param> /// <param name="ctor"></param> /// <returns></returns> public override bool IsContextOK(Context context, IConstructionCallMessage ctor) { return context.GetProperty("Interception") != null; }
public override bool IsNewContextOK(Context newCtx) { return (newCtx != null) && (newCtx.GetProperty(Name) as InterceptProperty) != null; }
// <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; }
internal static Context CreateNewContext (IConstructionCallMessage msg) { // Create the new context Context newContext = new Context(); foreach (IContextProperty prop in msg.ContextProperties) { if (newContext.GetProperty (prop.Name) == null) newContext.SetProperty (prop); } newContext.Freeze(); // Ask each context property whether the new context is OK foreach (IContextProperty prop in msg.ContextProperties) if (!prop.IsNewContextOK (newContext)) throw new RemotingException("A context property did not approve the candidate context for activating the object"); return newContext; }
public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg) { return (ctx.GetProperty(Name) as InterceptProperty) != null; }