private ELContext CreateElContext(IScriptContext scriptCtx) { // Check if the ELContext is already stored on the ScriptContext object existingELCtx = scriptCtx.GetAttribute("elcontext"); if (existingELCtx is ELContext) { return((ELContext)existingELCtx); } scriptCtx.SetAttribute("context", scriptCtx, ScriptContext_Fields.ENGINE_SCOPE); // Built-in function are added to ScriptCtx scriptCtx.SetAttribute("out:print", GetPrintMethod(), ScriptContext_Fields.ENGINE_SCOPE); //SecurityManager securityManager = System.getSecurityManager(); //if (securityManager == null) //{ scriptCtx.SetAttribute("lang:import", getImportMethod(), ScriptContext_Fields.ENGINE_SCOPE); //} ELContext elContext = new ELContextAnonymousInnerClassHelper(this, scriptCtx); // Store the elcontext in the scriptContext to be able to reuse scriptCtx.SetAttribute("elcontext", elContext, ScriptContext_Fields.ENGINE_SCOPE); return(elContext); }
public override MethodInfo ResolveFunction(string prefix, string localName) { string functionName = getFullFunctionName(prefix, localName); int scope = scriptContext.GetAttributesScope(functionName); if (scope != -1) { // Methods are added as variables in the ScriptScope object attributeValue = scriptContext.GetAttribute(functionName); return((attributeValue is MethodInfo) ? (MethodInfo)attributeValue : null); } else { return(null); } }
public override ValueExpression ResolveVariable(string variableName) { int scope = scriptContext.GetAttributesScope(variableName); if (scope != -1) { object value = scriptContext.GetAttribute(variableName, scope); if (value is ValueExpression) { // Just return the existing ValueExpression return((ValueExpression)value); } else { // Create a new ValueExpression based on the variable value return(outerInstance.expressionFactory.CreateValueExpression(value, typeof(object))); } } return(null); }