public static DWR_Class dwr_mapJavascriptIntoDwrClass(this DWR_Class dwrClass, string javascript)
        {
            var compiledJavascript = javascript.jint_Compile();
            var functions          = compiledJavascript.functions();

            foreach (var function in functions)
            {
                var statements = function.statements(true);
                if (statements.size() == 16 &&
                    statements[0].typeName() == "FunctionExpression" && statements[6].str() == "_path" &&
                    statements[7].typeName() == "Identifier" && statements[10].str() == "arguments")                      // this signature finds the dwr methods (which should always have the same format)
                {
                    var className          = statements[8].str();
                    var functionName       = statements[9].str();
                    var javascriptFunction = (FunctionExpression)statements[0];
                    var parameters         = javascriptFunction.Parameters;
                    var dwrFunction        = new DWR_Function(className, functionName, parameters);
                    dwrFunction.SourceCode = javascriptFunction.Source.Code;
                    dwrClass.Functions.add(dwrFunction);
                    //"Mapped function: {0}.{1}".debug(className, functionName);
                }
            }
            ;
            if (dwrClass.Functions.size() > 0)
            {
                dwrClass.ClassName = dwrClass.Functions[0].ClassName;                 // need to change this with code that gets the value from the AST
            }
            return(dwrClass);
        }
 public static string saveRequestToFolder(this DWR_Request dwr_Request, DWR_Function function, string folder)
 {
     try
     {
         var fileName = dwr_Request.postRequest_safeFileName(function, folder);
         dwr_Request.serialize(fileName);
         return(fileName);
     }
     catch
     {
         return(Files.Copy(dwr_Request.serialize(), folder));
     }
 }
        //I was trying to do the above search for handleNewScriptSession using jint but it wasn't working (part of the problem was going upwards once found the PropertyExpression with handleNewScriptSession

        /*
         * treeView.jint_configureTreeViewFor_JintView();
         *
         *
         * var jintCompiled = responseData.jint_Compile();
         * var handleNewScriptSession = (from memberExpression in jintCompiled.statements<MemberExpression>(true)
         *                                                        where memberExpression.Member is PropertyExpression  &&
         *                                                              (memberExpression.Member as PropertyExpression).Text == "handleNewScriptSession"
         *                                                        select memberExpression
         *                                                        ).first(); */


        public static string postRequest_safeFileName(this DWR_Request dwr_Request, DWR_Function function, string folder)
        {
            return(folder.pathCombine("{0}.{1} - {2}.xml".format(function.ClassName, function, dwr_Request.RequestEndDate).safeFileName(240 - folder.size())));
        }
 public DWR_Request invoke(DWR_Function dwrFunction)
 {
     return(invoke(dwrFunction.ClassName, dwrFunction.FunctionName, dwrFunction.Parameters.getDefaultValues()));
 }