// Args := {trade_ctrl, stop_strat,[StratID::atom(), OpDescr::string(), User::int()]} // nfx_crud:rpc(ReqID, Mod, Fun, Args) private static parsedQuery prepareQuery(QuerySource qSource) { var src = qSource.StatementSource; parsedQuery result; if (s_ParsedQueryCache.TryGetValue(src, out result)) { return(result); } try { var mfa = NFX.Erlang.ErlObject.ParseMFA(src); var argsTerm = mfa.Item3; var vars = argsTerm.Visit(new HashSet <ErlVar>(), (a, o) => { if (o is ErlVar) { a.Add((ErlVar)o); } return(a); }); result = new parsedQuery() { Source = src, Module = mfa.Item1, Function = mfa.Item2, ArgTerm = argsTerm, ArgVars = vars }; } catch (Exception error) { throw new ErlDataAccessException(StringConsts.ERL_DS_QUERY_SCRIPT_PARSE_ERROR.Args(src, error.ToMessageWithType()), error); } var dict = new Dictionary <string, parsedQuery>(s_ParsedQueryCache, StringComparer.Ordinal); dict[src] = result; s_ParsedQueryCache = dict;//atomic return(result); }
// Args := {trade_ctrl, stop_strat,[StratID::atom(), OpDescr::string(), User::int()]} // nfx_crud:rpc(ReqID, Mod, Fun, Args) private static parsedQuery prepareQuery(QuerySource qSource) { var src = qSource.StatementSource; parsedQuery result; if (s_ParsedQueryCache.TryGetValue(src, out result)) return result; try { var mfa = NFX.Erlang.ErlObject.ParseMFA(src); var argsTerm = mfa.Item3; var vars = argsTerm.Visit(new HashSet<ErlVar>(), (a, o) => { if (o is ErlVar) a.Add((ErlVar)o); return a; }); result = new parsedQuery() { Source = src, Module = mfa.Item1, Function = mfa.Item2, ArgTerm = argsTerm, ArgVars = vars }; } catch(Exception error) { throw new ErlDataAccessException(StringConsts.ERL_DS_QUERY_SCRIPT_PARSE_ERROR.Args(src, error.ToMessageWithType()), error); } var dict = new Dictionary<string, parsedQuery>(s_ParsedQueryCache, StringComparer.Ordinal); dict[src] = result; s_ParsedQueryCache = dict;//atomic return result; }