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 DWR_Class dwr_mapJavascriptIntoDwrClass(this string uriOrJavascript, Func <DWR_Class, string, DWR_Class> mapingFunction) { var dwr_Class = new DWR_Class(); var javascript = ""; if (uriOrJavascript.isUri()) { "[DWR] fetching data from: {0}".info(uriOrJavascript); var html = uriOrJavascript.uri().getHtml(); html = html.replace("new this()", "new this___()"); // jint bug //var dwrClass = html.dwr_mapJavascriptIntoDwrClass(); dwr_Class.SourceCode = html; javascript = html; } else { javascript = uriOrJavascript; } return(mapingFunction(dwr_Class, javascript)); }