/// <summary> /// /// </summary> /// <param name="query"></param> /// <param name="jsonqlAuthorization"></param> /// <returns></returns> public async Task <string> Handle(string query, IJsonqlAuthorization jsonqlAuthorization) { using (var queryParser = new QueryParser(query)) { resources = queryParser.Resources.ToDictionary(_ => _.Key, _ => resourceTable.GetResource(_.Value, jsonqlAuthorization, jsonqlIncluder, jsonqlLinqer)); expressions = queryParser.Expressions.Copy(); templates = queryParser.Templates.Copy(); entry = queryParser.Entry; } var @object = await createObject(templates[entry]); return(JsonConvert.SerializeObject(@object)); }
internal Resource GetResource(string template, IJsonqlAuthorization jsonqlAuthorization, IJsonqlIncluder jsonqlIncluder = null, IJsonqlLinqer jsonqlLinqer = null) { var name = template.Substring(0, template.IndexOf("[]")); var queryable = queryables[name]; if (queryable == null) { return(null); } if (filters.ContainsKey(name)) { filters[name]?.Invoke(queryable, jsonqlAuthorization); } return(new Resource(queryable, jsonqlIncluder, jsonqlLinqer)); }