public object Execute(Expression expression) { var updater = new QueryModifier(); expression = updater.Visit(expression); if (updater.Source == null) { throw new InvalidOperationException(); } var result = updater.Source.Provider.Execute(expression); return(result); }
public IQueryable CreateQuery(Expression expression) { var updater = new QueryModifier(); expression = updater.Visit(expression); if (updater.Source == null) { throw new InvalidOperationException(); } var result = updater.Source.Provider.CreateQuery(expression); return(result); }
public IQueryable <TElement> CreateQuery <TElement>(Expression expression) { if (!(expression is MethodCallExpression mc)) { throw new ArgumentException("Invalid expression", nameof(expression)); } var queryable = ConstantFinder <IQueryable <TSource> > .FindIn(mc.Arguments[0]); if (queryable == null) { throw new InvalidOperationException("Cannot find source."); } if (mc.Method.TryFindMethod(out var method)) { var arguments = mc.Arguments.Select(x => LambdaFinder.FindIn(x) ?? ConstantFinder <object> .FindIn(x)).ToArray(); return((IQueryable <TElement>)method.Invoke(null, arguments)); } var source = new Lazy <IEnumerable <TSource> >(() => (queryable as IQueryableCollection <TSource>)?.Source ?? queryable); var collection = new Lazy <IReadOnlyObservableCollection <TSource> >(() => source.Value as IReadOnlyObservableCollection <TSource>); var list = new Lazy <IReadOnlyObservableList <TSource> >(() => source.Value as IReadOnlyObservableList <TSource>); switch (mc.Method.Name) { case "OfType" when mc.Arguments.Count == 1 && collection.Value != null: return(list.Value != null ? new CastingReadOnlyObservableList <TSource, TElement>(list.Value.ListWhere(x => x is TElement)).AsQueryableCollection() : new CastingReadOnlyObservableCollection <TSource, TElement>(source.Value.ListWhere(x => x is TElement)).AsQueryableCollection()); case "Cast" when mc.Arguments.Count == 1 && collection.Value != null: return(list.Value != null ? new CastingReadOnlyObservableList <TSource, TElement>(list.Value).AsQueryableCollection() : new CastingReadOnlyObservableCollection <TSource, TElement>(collection.Value).AsQueryableCollection()); } var updater = new QueryModifier(); expression = updater.Visit(expression); if (updater.Source == null) { throw new InvalidOperationException(); } var result = updater.Source.Provider.CreateQuery <TElement>(expression); return(result); }
private void AttackPOST(string URL, string POST) { if (string.IsNullOrEmpty(POST)) { return; } for (int i = 0; i < AttackedUrls.Count; i++) { if (AttackedUrls[i].OriginalURL == URL && AttackedUrls[i].OriginalPOST == POST) { return; } } QueryModifier queryModifier = new QueryModifier(POST); if (queryModifier.ParameterCount == 0) { return; } do { string NewPOST = queryModifier.GetModifiedQuery(textBoxModifier.Text); DateTime Start = DateTime.Now; CreateWebrequest Request = new CreateWebrequest(); string HTML = Request.StringGetWebPage(URL, POST, new List <string>(), false); AttackedUrl attackedURL = new AttackedUrl(); attackedURL.HTML = HTML; attackedURL.OriginalPOST = POST; attackedURL.OriginalURL = URL; attackedURL.ModifiedPOST = NewPOST; AttackedUrls.Add(attackedURL); ClearAttackBrowser(); ListViewItem Item = new ListViewItem(); Item.Text = URL; Item.SubItems.Add(NewPOST); listViewResult.Items.Add(Item); }while (queryModifier.NextParameter()); }
private void AttackURL(string URL) { if (!URL.Contains("?")) { return; } for (int i = 0; i < AttackedUrls.Count; i++) { if (AttackedUrls[i].OriginalURL == URL && string.IsNullOrEmpty(AttackedUrls[i].OriginalPOST)) { return; } } string Query = URL.Substring(URL.IndexOf('?') + 1); string BeforeQuery = URL.Substring(0, URL.IndexOf('?') + 1); QueryModifier queryModifier = new QueryModifier(Query); if (queryModifier.ParameterCount != 0) { do { string NewURL = BeforeQuery + queryModifier.GetModifiedQuery(textBoxModifier.Text); DateTime Start = DateTime.Now; CreateWebrequest Request = new CreateWebrequest(); string HTML = Request.StringGetWebPage(NewURL, string.Empty, new List <string>(), false); AttackedUrl attackedURL = new AttackedUrl(); attackedURL.HTML = HTML; attackedURL.OriginalURL = URL; attackedURL.ModifiedURL = NewURL; AttackedUrls.Add(attackedURL); ClearAttackBrowser(); ListViewItem Item = new ListViewItem(); Item.Text = NewURL; Item.SubItems.Add(string.Empty); listViewResult.Items.Add(Item); }while (queryModifier.NextParameter()); } }
public TResult Execute <TResult>(Expression expression) { if (expression is MethodCallExpression mc) { if (mc.Method.TryFindMethod(out var method)) { var arguments = mc.Arguments.Select(x => LambdaFinder.FindIn(x) ?? ConstantFinder <object> .FindIn(x)).ToArray(); return((TResult)method.Invoke(null, arguments)); } } var updater = new QueryModifier(); expression = updater.Visit(expression); if (updater.Source == null) { throw new InvalidOperationException(); } var result = updater.Source.Provider.Execute <TResult>(expression); return(result); }