private static void Validate <TEntity>(FilterQuery filterQuery) { if (!string.IsNullOrWhiteSpace(filterQuery.OrderBy)) { ValidateOrderBy <TEntity>(filterQuery.OrderBy); } }
public Task Filter() { if (!FilterQuery.IsNullOrEmpty()) { try { if (FilterQuery != _lastFilterQuery) { if (_lastFilterQuery.IsNullOrEmpty()) { _cachedEvents = Events; } _lastFilterQuery = FilterQuery; char[] toTrim = { ' ', '"', '\'' }; var query = FilterQuery.Trim(toTrim); Events = _dbs.GetEvents(query).ToObservableCollection(); } } catch (Newtonsoft.Json.JsonException) { throw new FormatException("Incorrect oauth token file format. Restore or delete it and try again"); } catch (DataException) { throw new DataException("Failed to modify database. Verify the connection and try again"); } } else if (_cachedEvents != null) { Events = _cachedEvents; } return(Task.CompletedTask); }
private IQueryable <Project> GetFilteredProjects(FilterQuery query) { var projectsDtos = _unitOfWork.Repository <Project>() .GetAll(); return(query.Filter(projectsDtos)); }
public static FilterQuery MeshResult(MeshResultSmoothingType smoothing, MeshResultLayer layer, double layerPosition, MeshResultType resultType, Cartesian coordinateSystem = null, IEnumerable <object> cases = null, IEnumerable <object> objectIds = null) { FilterQuery query = new FilterQuery(); query.Type = typeof(MeshResults); query.Equalities["Smoothing"] = smoothing; query.Equalities["Layer"] = layer; query.Equalities["LayerPosition"] = layerPosition; query.Equalities["ResultType"] = resultType; query.Equalities["CoordinateSystem"] = coordinateSystem; if (cases != null) { query.Equalities["Cases"] = cases.ToList(); } if (objectIds != null) { query.Equalities["ObjectIds"] = objectIds.ToList(); } return(query); }
public static QueryWrapper <T> Filter <T, TField>(this QueryWrapper <T> wrapper, FilterQuery <TField> query, Expression <Func <T, object> > path) where T : class => wrapper.QueryInternal( query, descriptor => { var container = null as QueryContainer; foreach (var value in query.Values) { var c = descriptor.Term(t => t.Field(path).Value(value)); if (container == null) { container = c; } else { switch (query.Mode) { default: container &= c; break; case QueryMatchMode.Any: container |= c; break; } } } return(container); });
/// <summary> /// It will rotate between all the available filters of project and return the next one. /// If the limit is reached it will started from the beginning /// </summary> /// <returns></returns> public async Task <FilterQuery> GetFilterProject(bool switchFilter = false) { FilterQuery filter = null; if (ProjectFilters != null) { if (switchFilter) { currentProjectFilter++; if (currentProjectFilter >= this.ProjectFilters.Length) { currentProjectFilter = 0; } } filter = ProjectFilters[currentProjectFilter]; if (filter != null && filter.Result == null && await this.LoadReferenceData <msdyn_project>(filter.QueryExpression)) { filter.Result = this.GetReferenceKeys <msdyn_project>(); } } return(filter); }
public RequestFilter(string fieldName, string value) { Filtering = new FilterQuery[] { new FilterQuery(fieldName, FilterClauseEnum.And, FilterConditionEnum.Eq, value) }; }
private string ComposeSingleFilter(FilterQuery query) { var result = "&filter"; result += QueryConstants.OPEN_BRACKET + query.Attribute + QueryConstants.CLOSE_BRACKET + query.Operation + query.Value; return(result); }
private FilterQueryContext GetQueryContexts(FilterQuery query, string parameterName) { var queryContext = new FilterQueryContext(query); var customQuery = _requestResourceDefinition?.GetCustomQueryFilter(query.Target); if (customQuery != null) { queryContext.IsCustom = true; queryContext.CustomQuery = customQuery; return(queryContext); } queryContext.Relationship = GetRelationship(parameterName, query.Relationship); var attribute = GetAttribute(parameterName, query.Attribute, queryContext.Relationship); if (queryContext.Relationship is HasManyAttribute) { throw new InvalidQueryStringParameterException(parameterName, "Filtering on one-to-many and many-to-many relationships is currently not supported.", $"Filtering on the relationship '{queryContext.Relationship.PublicRelationshipName}.{attribute.PublicAttributeName}' is currently not supported."); } if (!attribute.Capabilities.HasFlag(AttrCapabilities.AllowFilter)) { throw new InvalidQueryStringParameterException(parameterName, "Filtering on the requested attribute is not allowed.", $"Filtering on attribute '{attribute.PublicAttributeName}' is not allowed."); } queryContext.Attribute = attribute; return(queryContext); }
//private static void TestPushElements(ETABSAdapter app) //{ // Console.WriteLine("Testing Push Bars ..."); // Point p1 = new Point { X = 0, Y = 0, Z = 0 }; // Point p2 = new Point { X = 1, Y = 0, Z = 0 }; // Point p3 = new Point { X = 1, Y = 1, Z = 0 }; // Point p4 = new Point { X = 0, Y = 1, Z = 0 }; // Point p5 = new Point { X = 0, Y = 0, Z = 1 }; // Point p6 = new Point { X = 1, Y = 0, Z = 1 }; // Point p7 = new Point { X = 1, Y = 1, Z = 1 }; // Point p8 = new Point { X = 0, Y = 1, Z = 1 }; // Point p5b = new Point { X = 0, Y = 0, Z = 2 }; // Point p6b = new Point { X = 1, Y = 0, Z = 2 }; // Point p7b = new Point { X = 1, Y = 1, Z = 2 }; // Point p8b = new Point { X = 0, Y = 1, Z = 2 }; // Constraint6DOF pin = BH.Engine.Structure.Create.PinConstraint6DOF(); // Constraint6DOF fix = BH.Engine.Structure.Create.FixConstraint6DOF(); // Constraint6DOF full = BH.Engine.Structure.Create.FullReleaseConstraint6DOF(); // List<Node> nodesA = new List<Node>(); // Node n1a = BH.Engine.Structure.Create.Node(p5 , "1"); // Node n2a = BH.Engine.Structure.Create.Node( p6 , "2" ); // Node n3a = BH.Engine.Structure.Create.Node( p7 , "3" ); // Node n4a = BH.Engine.Structure.Create.Node( p8 , "4" ); // n1a.Constraint = pin; // n2a.Constraint = pin; // n3a.Constraint = fix; // n4a.Constraint = fix; // nodesA.Add(n1a); // nodesA.Add(n2a); // nodesA.Add(n3a); // nodesA.Add(n4a); // List<Node> nodesB = new List<Node>(); // Node n1b = BH.Engine.Structure.Create.Node( p5b, "1" ); // Node n2b = BH.Engine.Structure.Create.Node( p6b, "2" ); // Node n3b = BH.Engine.Structure.Create.Node( p7b, "3" ); // Node n4b = BH.Engine.Structure.Create.Node( p8b, "4" ); // n1b.Constraint = pin; // n2b.Constraint = pin; // n3b.Constraint = full; // n4b.Constraint = fix; // nodesB.Add(n1b); // nodesB.Add(n2b); // nodesB.Add(n3b); // nodesB.Add(n4b); // Bar bar1 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p1), BH.Engine.Structure.Create.Node( p2)); // Bar bar2 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p2), BH.Engine.Structure.Create.Node( p3)); // Bar bar3 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p3), BH.Engine.Structure.Create.Node( p4)); // Bar bar4 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p4), BH.Engine.Structure.Create.Node( p1)); // Bar bar5 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p5), BH.Engine.Structure.Create.Node( p6)); // Bar bar6 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p6), BH.Engine.Structure.Create.Node( p7)); // Bar bar7 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p7), BH.Engine.Structure.Create.Node( p8)); // Bar bar8 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p8), BH.Engine.Structure.Create.Node( p5)); // Bar bar9 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p1), BH.Engine.Structure.Create.Node( p5)); // Bar bar10 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p2), BH.Engine.Structure.Create.Node( p6)); // Bar bar11 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p3), BH.Engine.Structure.Create.Node( p7)); // Bar bar12 = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p4), BH.Engine.Structure.Create.Node( p8)); // Bar bar5b = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p5b), BH.Engine.Structure.Create.Node( p6b)); // Bar bar6b = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p6b), BH.Engine.Structure.Create.Node( p7b)); // Bar bar7b = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p7b), BH.Engine.Structure.Create.Node( p8b)); // Bar bar8b = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p8b), BH.Engine.Structure.Create.Node( p5b)); // Bar bar9b = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p1), BH.Engine.Structure.Create.Node( p5b)); // Bar bar10b = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p2), BH.Engine.Structure.Create.Node( p6b)); // Bar bar11b = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p3), BH.Engine.Structure.Create.Node( p7b)); // Bar bar12b = BH.Engine.Structure.Create.Bar(BH.Engine.Structure.Create.Node( p4), BH.Engine.Structure.Create.Node( p8b)); // List<Bar> bars1 = new List<Bar>(); // List<Bar> bars2a = new List<Bar>(); // List<Bar> bars2b = new List<Bar>(); // bars1.Add(bar1); // bars1.Add(bar2); // bars1.Add(bar3); // bars1.Add(bar4); // bars2a.Add(bar5); // bars2a.Add(bar6); // bars2a.Add(bar7); // bars2a.Add(bar8); // bars2a.Add(bar9); // bars2a.Add(bar10); // bars2a.Add(bar11); // bars2a.Add(bar12); // bars2b.Add(bar5b); // bars2b.Add(bar6b); // bars2b.Add(bar7b); // bars2b.Add(bar8b); // bars2b.Add(bar9b); // bars2b.Add(bar10b); // bars2b.Add(bar11b); // bars2b.Add(bar12b); // //Material steel = BH.Engine.Common.Create.Material("Steel", MaterialType.Steel, 210000, 0.3, 0.00012, 78500); // ISectionProperty sec1 = BH.Engine.Structure.Create.SteelISection(110, 10, 80, 20); // //sec1.Material = steel;// BH.Engine.Common.Create.Material("Steel", MaterialType.Steel, 210000, 0.3, 0.00012, 78500); //BH.Engine.Common.Create.Material("blue steel");//<-- this creates material of type aluminium // sec1.Name = "Section 1"; // ISectionProperty sec2a = BH.Engine.Structure.Create.ConcreteRectangleSection(200, 120); // //sec2a.Material = BH.Engine.Common.Create.Material("myConcrete", MaterialType.Concrete, 10, 10, 10, 10); // sec2a.Name = "Section 2a"; // ISectionProperty sec2b = new ExplicitSection(); // //sec2b.Material = BH.Engine.Common.Create.Material("otherSteel", MaterialType.Steel, 210000, 0.3, 0.00012, 78500); // sec2b.Name = "Section 2b"; // foreach (Bar b in bars1) // b.SectionProperty = sec1; // foreach (Bar b in bars2a) // b.SectionProperty = sec2a; // foreach (Bar b in bars2b) // b.SectionProperty = sec2b; // List<Panel> panels = new List<Panel>(); // Polyline outline = new Polyline(); // outline.ControlPoints = new List<Point>() { p1, p2, p3, p4, p1 }; // // Material steel = sec1.Material;// BH.Engine.Common.Create.Material("panelSteel"); // ISurfaceProperty panelProp = BH.Engine.Structure.Create.ConstantThickness(100, steel); // panelProp.Name = "panelProperty"; // List<ICurve> nothing = null; // Panel panelA = BH.Engine.Structure.Create.Panel(outline, nothing); // panelA.Property = panelProp; // panels.Add(panelA); // outline.ControlPoints = new List<Point>() { p5, p6, p7, p8, p5 }; // Point op5 = new Point { X = 0.2, Y = 0.2, Z = 1 }; // Point op6 = new Point { X = 0.8, Y = 0.2, Z = 1 }; // Point op7 = new Point { X = 0.8, Y = 0.8, Z = 1 }; // Point op8 = new Point { X = 0.2, Y = 0.8, Z = 1 }; // Polyline hole = new Polyline() { ControlPoints = new List<Point>() { op5, op6, op7, op8 } }; // Opening opening = new Opening() { Edges = new List<Edge>() { new Edge() { Curve = hole } } }; // Panel panelB = BH.Engine.Structure.Create.Panel(outline, new List<Opening>() { opening }); // panelB.Property = panelProp; // panels.Add(panelB); // app.Push(nodesA, "Nodes"); // app.Push(nodesB, "Nodes"); // app.Push(bars1, "Bars1"); // app.Push(bars2a, "Bars2"); // app.Push(bars2b, "Bars2"); // app.Push(panels, "panels"); // Console.WriteLine("All elements Pushed !"); // Console.ReadLine(); //} private static void TestPullBars(ETABSAdapter app) { Console.WriteLine("Test Pull Bars"); FilterQuery nodeQuery = new FilterQuery { Type = typeof(Node) }; FilterQuery barQuery = new FilterQuery { Type = typeof(Bar) }; IEnumerable <object> barObjects = app.Pull(barQuery); int count = 0; foreach (object bObject in barObjects) { Bar bar = bObject as Bar; string barId = bar.CustomData[ETABSAdapter.ID].ToString(); string startNodeId = bar.StartNode.CustomData[ETABSAdapter.ID].ToString(); string endNodeId = bar.EndNode.CustomData[ETABSAdapter.ID].ToString(); string startPoint = bar.StartNode.Position().X.ToString() + "," + bar.StartNode.Position().Y.ToString() + "," + bar.StartNode.Position().Z.ToString(); string endPoint = bar.EndNode.Position().X.ToString() + "," + bar.EndNode.Position().Y.ToString() + "," + bar.EndNode.Position().Z.ToString(); string section = bar.SectionProperty.Name; string material = bar.SectionProperty.Material.Name; string barInfo = "Bar with ID: " + barId + " -Connecting Nodes " + startNodeId + " at " + startPoint + " and " + endNodeId + " at " + endPoint + " Section: " + section + " Material: " + material + "/n"; string barTags = string.Join("_/_", bar.Tags.ToArray()); Console.WriteLine(barInfo + barTags); } Console.WriteLine("Pulled all bars"); Console.WriteLine("... press enter to exit"); Console.ReadLine(); }
protected IQueryable <TEntity> ApplyFindCriteria <TEntity>( IQueryable <TEntity> query, FilterQuery filterQuery) where TEntity : class, IDataEntity { return(query.Filter(filterQuery)); }
private List <Patients> DateFilter(FilterQuery filterQuery, List <Patients> patients) { DateTime searchDate = new DateTime(); DateTime.TryParse(filterQuery.Value, out searchDate); switch ((PatientSearch)Enum.Parse(typeof(PatientSearch), filterQuery.Operation.ToUpper())) { case PatientSearch.FROMDATE: patients = _jsonApiContext.GetDbContextResolver().GetDbSet <Patients>().Where(o => o.CreatedDate >= searchDate && o.IsDeleted == false && o.IsActive == true).ToList(); _jsonApiContext.QuerySet.Filters.Remove(filterQuery); break; case PatientSearch.TODATE: patients = _jsonApiContext.GetDbContextResolver().GetDbSet <Patients>().Where(o => o.CreatedDate <= searchDate && o.IsDeleted == false && o.IsActive == true).ToList(); _jsonApiContext.QuerySet.Filters.Remove(filterQuery); break; case PatientSearch.FROMDOB: patients = _jsonApiContext.GetDbContextResolver().GetDbSet <Patients>().Where(o => o.DOB >= searchDate && o.IsDeleted == false && o.IsActive == true).ToList(); _jsonApiContext.QuerySet.Filters.Remove(filterQuery); break; case PatientSearch.TODOB: patients = _jsonApiContext.GetDbContextResolver().GetDbSet <Patients>().Where(o => o.DOB <= searchDate && o.IsDeleted == false && o.IsActive == true).ToList(); _jsonApiContext.QuerySet.Filters.Remove(filterQuery); break; } return(patients); }
public void TestFilterDouble() { //arange var domainList = new List <ExoticTestDomain>(); var filter = new ExoticFilterDTO(); IQueryable <ExoticTestDomain> query = domainList.AsQueryable(); //data domainList.Add(new ExoticTestDomain { DOUBLE_PROP = 1.1 }); domainList.Add(new ExoticTestDomain { DOUBLE_PROP = 2.2 }); domainList.Add(new ExoticTestDomain { DOUBLE_PROP = 3.3 }); //filter filter.DOUBLE_PROP = 1.1; //act query = FilterQuery.SetFilters <ExoticTestDomain, ExoticFilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.Count); }
private FilterQueryContext GetQueryContexts(FilterQuery query, string parameterName) { var queryContext = new FilterQueryContext(query); var customQuery = _requestResourceDefinition?.GetCustomQueryFilter(query.Target); if (customQuery != null) { queryContext.IsCustom = true; queryContext.CustomQuery = customQuery; return(queryContext); } queryContext.Relationship = GetRelationship(parameterName, query.Relationship); var attribute = GetAttribute(parameterName, query.Attribute, queryContext.Relationship); if (!attribute.IsFilterable) { throw new InvalidQueryStringParameterException(parameterName, "Filtering on the requested attribute is not allowed.", $"Filtering on attribute '{attribute.PublicAttributeName}' is not allowed."); } queryContext.Attribute = attribute; return(queryContext); }
public void TestFilterUshortNullable() { //arange var domainList = new List <ExoticTestDomain>(); var filter = new ExoticFilterDTO(); IQueryable <ExoticTestDomain> query = domainList.AsQueryable(); //data domainList.Add(new ExoticTestDomain { USHORT_PROP_NULLABLE = 1 }); domainList.Add(new ExoticTestDomain { USHORT_PROP_NULLABLE = 2 }); domainList.Add(new ExoticTestDomain { USHORT_PROP_NULLABLE = 3 }); //filter filter.USHORT_PROP_NULLABLE = 1; //act query = FilterQuery.SetFilters <ExoticTestDomain, ExoticFilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.Count); }
public void TestFilterFloatNullable() { //arange var domainList = new List <ExoticTestDomain>(); var filter = new ExoticFilterDTO(); IQueryable <ExoticTestDomain> query = domainList.AsQueryable(); //data domainList.Add(new ExoticTestDomain { FLOAT_PROP_NULLABLE = 1.1F }); domainList.Add(new ExoticTestDomain { FLOAT_PROP_NULLABLE = 2.2f }); domainList.Add(new ExoticTestDomain { FLOAT_PROP_NULLABLE = 3.3F }); //filter filter.FLOAT_PROP_NULLABLE = 1.1f; //act query = FilterQuery.SetFilters <ExoticTestDomain, ExoticFilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.Count); }
public async Task <IActionResult> Get([FromQuery] FilterQuery query) { _logger.LogInformation("Call search products...."); var response = await _productService.FilterProducts(query); return(Ok(response)); }
public async Task <IActionResult> Get(FilterQuery filter) { try { string pageString = HttpContext.Request.Headers["X-Pagination-Page"]; string resultPerPageString = HttpContext.Request.Headers["X-Pagination-ResultPerPage"]; Int32.TryParse(pageString, out int page); Int32.TryParse(resultPerPageString, out int resultsPerPage); PagedQueryBase query = new PagedQueryBase() { Page = page, ResultsPerPage = resultsPerPage, Filter = filter }; var ads = await _adService.BrowseAsync(query); return(Json(ads)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public virtual IActionResult Find([FromQuery] FilterQuery filterQuery) { var query = new FindQuery <TModel>(filterQuery); var result = QueryDispatcher.Dispatch(query); return(Ok(result)); }
public FilterRequest RoleFilter(FilterQuery queryString) { var searchQuery = ""; if (!string.IsNullOrEmpty(queryString.filter)) { var _filter = JsonConvert.DeserializeObject <RoleFilter>(queryString.filter); searchQuery += "("; var searchCount = 0; if (!string.IsNullOrEmpty(_filter.role_name)) { searchQuery += " role_name LIKE ('%" + _filter.role_name + "%') "; searchCount++; } searchQuery += ")"; } else { searchQuery += " role_name LIKE ('%" + queryString.search + "%') "; } return(new FilterRequest() { SearchType = 0, Skip = queryString.offset, Take = queryString.limit, SortDir = queryString.order ?? "desc", SortCol = queryString.sort ?? "created_on", SearchCol = string.Empty, SearchText = searchQuery ?? "" }); }
private IQueryable <UserDetails> GetFilteredProjects(FilterQuery query) { var userDtos = _unitOfWork.Repository <UserDetails>() .GetAll(); return(query.UserFilter(userDtos)); }
public void TestFilterEqualsSingleNumberResultValidityEquals() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { ID = 1 }); domainList.Add(new TestDomain { ID = 2 }); domainList.Add(new TestDomain { ID = 3 }); domainList.Add(new TestDomain { ID = 4 }); domainList.Add(new TestDomain { ID = 5 }); var filter = new FilterDTO(); filter.Id = 1; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.FirstOrDefault().ID); }
private FilterQueryContext GetQueryContexts(FilterQuery query) { var queryContext = new FilterQueryContext(query); if (_requestResourceDefinition != null) { var customQuery = _requestResourceDefinition.GetCustomQueryFilter(query.Target); if (customQuery != null) { queryContext.IsCustom = true; queryContext.CustomQuery = customQuery; return(queryContext); } } queryContext.Relationship = GetRelationship(query.Relationship); var attribute = GetAttribute(query.Attribute, queryContext.Relationship); if (attribute.IsFilterable == false) { throw new JsonApiException(400, $"Filter is not allowed for attribute '{attribute.PublicAttributeName}'."); } queryContext.Attribute = attribute; return(queryContext); }
public IActionResult GetVehicles([FromQuery] FilterQuery filterQuery) { try { var vehicles = _repo.GetVehicles(filterQuery); var metadata = new { vehicles.TotalCount, vehicles.PageSize, vehicles.CurrentPage, vehicles.TotalPages, vehicles.HasNext, vehicles.HasPrevious }; if (vehicles == null) { return(NotFound()); } var vehiclesToReturn = _mapper.Map <IEnumerable <VehicleForListDto> >(vehicles); Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok(vehiclesToReturn)); } catch (Exception) { return(BadRequest()); } }
private string ComposeSingleFilter(FilterQuery query) { var result = "&filter"; var operation = string.IsNullOrWhiteSpace(query.Operation) ? query.Operation : query.Operation + ":"; result += QueryConstants.OPEN_BRACKET + query.Attribute + QueryConstants.CLOSE_BRACKET + "=" + operation + query.Value; return(result); }
public void Replace(FilterQuery input) { RakNetPINVOKE.RakNetListFilterQuery_Replace__SWIG_1(swigCPtr, FilterQuery.getCPtr(input)); if (RakNetPINVOKE.SWIGPendingException.Pending) { throw RakNetPINVOKE.SWIGPendingException.Retrieve(); } }
public void Push(FilterQuery input, string file, uint line) { RakNetPINVOKE.RakNetListFilterQuery_Push(swigCPtr, FilterQuery.getCPtr(input), file, line); if (RakNetPINVOKE.SWIGPendingException.Pending) { throw RakNetPINVOKE.SWIGPendingException.Retrieve(); } }
protected void RemoveFilter_Click(object sender, EventArgs e) { FilterQueryCollection existingQueries = new FilterQueryCollection(hidFilterQueries.Value); FilterQuery fq = new FilterQuery(((LinkButton)sender).CommandArgument); existingQueries.Remove(fq); Query(null, 0, hidLoggingId.Value, existingQueries); }
public IEnumerable <DataModelIssue> Filter(IEnumerable <DataModelIssue> issues) { if (FilterQuery == null) { return(issues); } return(issues.Where(i => ((i.Repo != this) || FilterQuery.Evaluate(i)))); }
protected void AddFilter_Click(object sender, EventArgs e) { FilterQueryCollection existingQueries = new FilterQueryCollection(hidFilterQueries.Value); FilterQuery fq = new FilterQuery(((LinkButton)sender).CommandArgument); existingQueries.Add(fq); UpdateFilters(existingQueries); }
private FilterQuery(FilterQuery other) : base(other) { this.cond = Clone(other.cond); this.noPosition = other.noPosition; }
private Query ProcessFilter(Filter root, Flags flags, out Props props) { bool first = ((flags & Flags.Filter) == 0); Props propsCond; Query cond = ProcessNode(root.Condition, Flags.None, out propsCond); if ( CanBeNumber(cond) || (propsCond & (Props.HasPosition | Props.HasLast)) != 0 ) { propsCond |= Props.HasPosition; flags |= Flags.PosFilter; } // We don't want DescendantOverDescendant pattern to be recognized here (in case descendent::foo[expr]/descendant::bar) // So we clean this flag here: flags &= ~Flags.SmartDesc; Query qyInput = ProcessNode(root.Input, flags | Flags.Filter, out props); if (root.Input.Type != AstNode.AstType.Filter) { // Props.PosFilter is for nested filters only. // We clean it here to avoid cleaning it in all other ast nodes. props &= ~Props.PosFilter; } if ((propsCond & Props.HasPosition) != 0) { // this condition is positional rightmost filter should be avare of this. props |= Props.PosFilter; } /*merging predicates*/ { FilterQuery qyFilter = qyInput as FilterQuery; if (qyFilter != null && (propsCond & Props.HasPosition) == 0 && qyFilter.Condition.StaticType != XPathResultType.Any) { Query prevCond = qyFilter.Condition; if (prevCond.StaticType == XPathResultType.Number) { prevCond = new LogicalExpr(Operator.Op.EQ, new NodeFunctions(FT.FuncPosition, null), prevCond); } cond = new BooleanExpr(Operator.Op.AND, prevCond, cond); qyInput = qyFilter.qyInput; } } if ((props & Props.PosFilter) != 0 && qyInput is DocumentOrderQuery) { qyInput = ((DocumentOrderQuery)qyInput).input; } if (firstInput == null) { firstInput = qyInput as BaseAxisQuery; } bool merge = (qyInput.Properties & QueryProps.Merge ) != 0; bool reverse = (qyInput.Properties & QueryProps.Reverse) != 0; if ((propsCond & Props.HasPosition) != 0) { if (reverse) { qyInput = new ReversePositionQuery(qyInput); } else if ((propsCond & Props.HasLast) != 0) { qyInput = new ForwardPositionQuery(qyInput); } } if (first && firstInput != null) { if (merge && (props & Props.PosFilter) != 0) { qyInput = new FilterQuery(qyInput, cond, /*noPosition:*/false); Query parent = firstInput.qyInput; if (! (parent is ContextQuery)) { // we don't need to wrap filter with MergeFilterQuery when cardinality is parent <: ? firstInput.qyInput = new ContextQuery(); firstInput = null; return new MergeFilterQuery(parent, qyInput); } firstInput = null; return qyInput; } firstInput = null; } return new FilterQuery(qyInput, cond, /*noPosition:*/(propsCond & Props.HasPosition) == 0); }
private FilterQuery(FilterQuery other) : base(other) { _cond = Clone(other._cond); _noPosition = other._noPosition; }
public string CreateFilterQuery() { switch (_option) { case SearchOption.Local: case SearchOption.CurrentTab: var pan = SplitPositiveNegativeQuery(_query); var query = pan.Item1.Select(s => "text contains " + s.EscapeForQuery().Quote()) .Concat(pan.Item2.Select(s => "!(text contains " + s.EscapeForQuery().Quote() + ")")) .JoinString("&&"); var ctab = TabManager.CurrentFocusTab; var ctf = ctab != null ? ctab.FilterQuery : null; if (this._option != SearchOption.CurrentTab || ctf == null) { return "where " + query; } var cqf = QueryCompiler.CompileFilters(query); var filters = ctf.PredicateTreeRoot.Operator; var nfq = new FilterQuery { Sources = ctf.Sources.ToArray(), PredicateTreeRoot = new FilterExpressionRoot { Operator = filters.And(cqf.Operator) } }; return nfq.ToQuery(); case SearchOption.Query: return this._filterQuery == null ? "!()" : this._query; case SearchOption.Web: return "from search:" + this._query.EscapeForQuery().Quote() + " where ()"; default: throw new ArgumentOutOfRangeException(); } }
private Func<TwitterStatus, bool> CreatePredicate(string query, SearchOption option) { if (option == SearchOption.Query) { try { return (_localQuery = QueryCompiler.Compile(query)).GetEvaluator(); } catch { return _ => false; } } var splitted = query.Split(new[] { " ", "\t", " " }, StringSplitOptions.RemoveEmptyEntries) .Distinct().ToArray(); var positive = splitted.Where(s => !s.StartsWith("-")).ToArray(); var negative = splitted.Where(s => s.StartsWith("-")).Select(s => s.Substring(1)).ToArray(); return status => positive.Any(s => status.Text.IndexOf(s, StringComparison.CurrentCultureIgnoreCase) >= 0) && !negative.Any(s => status.Text.IndexOf(s, StringComparison.CurrentCultureIgnoreCase) >= 0); }
private Query ProcessFilter(Filter root, Flags flags, out Props props) { bool first = ((flags & Flags.Filter) == 0); Props propsCond; Query cond = ProcessNode(root.Condition, Flags.None, out propsCond); if ( CanBeNumber(cond) || (propsCond & (Props.HasPosition | Props.HasLast)) != 0 ) { propsCond |= Props.HasPosition; flags |= Flags.PosFilter; } // We don't want DescendantOverDescendant pattern to be recognized here (in case descendent::foo[expr]/descendant::bar) // So we clean this flag here: flags &= ~Flags.SmartDesc; // ToDo: Instead it would be nice to wrap descendent::foo[expr] into special query that will flatten it -- i.e. // remove all nodes that are descendant of other nodes. This is very easy because for sorted nodesets all children // follow its parent. One step caching. This can be easily done by rightmost DescendantQuery itself. // Interesting note! Can we guarantee that DescendantOverDescendant returns flat nodeset? This definitely true if it's input is flat. Query qyInput = ProcessNode(root.Input, flags | Flags.Filter, out props); if (root.Input.Type != AstNode.AstType.Filter) { // Props.PosFilter is for nested filters only. // We clean it here to avoid cleaning it in all other ast nodes. props &= ~Props.PosFilter; } if ((propsCond & Props.HasPosition) != 0) { // this condition is positional rightmost filter should be avare of this. props |= Props.PosFilter; } /*merging predicates*/ { FilterQuery qyFilter = qyInput as FilterQuery; if (qyFilter != null && (propsCond & Props.HasPosition) == 0 && qyFilter.Condition.StaticType != XPathResultType.Any) { Query prevCond = qyFilter.Condition; if (prevCond.StaticType == XPathResultType.Number) { prevCond = new LogicalExpr(Operator.Op.EQ, new NodeFunctions(FT.FuncPosition, null), prevCond); } cond = new BooleanExpr(Operator.Op.AND, prevCond, cond); qyInput = qyFilter.qyInput; } } if ((props & Props.PosFilter) != 0 && qyInput is DocumentOrderQuery) { qyInput = ((DocumentOrderQuery)qyInput).input; } if (_firstInput == null) { _firstInput = qyInput as BaseAxisQuery; } bool merge = (qyInput.Properties & QueryProps.Merge) != 0; bool reverse = (qyInput.Properties & QueryProps.Reverse) != 0; if ((propsCond & Props.HasPosition) != 0) { if (reverse) { qyInput = new ReversePositionQuery(qyInput); } else if ((propsCond & Props.HasLast) != 0) { qyInput = new ForwardPositionQuery(qyInput); } } if (first && _firstInput != null) { if (merge && (props & Props.PosFilter) != 0) { qyInput = new FilterQuery(qyInput, cond, /*noPosition:*/false); Query parent = _firstInput.qyInput; if (!(parent is ContextQuery)) { // we don't need to wrap filter with MergeFilterQuery when cardinality is parent <: ? _firstInput.qyInput = new ContextQuery(); _firstInput = null; return new MergeFilterQuery(parent, qyInput); } _firstInput = null; return qyInput; } _firstInput = null; } return new FilterQuery(qyInput, cond, /*noPosition:*/(propsCond & Props.HasPosition) == 0); }
private async Task<bool> CheckCompile(string source) { try { var newFilter = await Task.Run(() => QueryCompiler.Compile(source)); newFilter.GetEvaluator(); // validate types _lastValidFilterQuery = newFilter; _lastValidFilterQueryString = source; FoundError = false; return true; } catch (Exception ex) { FoundError = true; ExceptionMessage = ex.Message; return false; } }
private async void CheckCompile(string source) { try { var newFilter = await Task.Run(() => QueryCompiler.Compile(source)); newFilter.GetEvaluator(); // validate types _filterQuery = newFilter; FoundError = false; } catch (Exception ex) { FoundError = true; ExceptionMessage = ex.Message; } }
private Query ProcessFilter(MS.Internal.Xml.XPath.Filter root, Flags flags, out Props props) { Props props2; bool flag = (flags & Flags.Filter) == Flags.None; Query q = this.ProcessNode(root.Condition, Flags.None, out props2); if (this.CanBeNumber(q) || ((props2 & (Props.HasLast | Props.HasPosition)) != Props.None)) { props2 |= Props.HasPosition; flags |= Flags.PosFilter; } flags &= ~Flags.SmartDesc; Query input = this.ProcessNode(root.Input, flags | Flags.Filter, out props); if (root.Input.Type != AstNode.AstType.Filter) { props &= ~Props.PosFilter; } if ((props2 & Props.HasPosition) != Props.None) { props |= Props.PosFilter; } FilterQuery query3 = input as FilterQuery; if (((query3 != null) && ((props2 & Props.HasPosition) == Props.None)) && (query3.Condition.StaticType != XPathResultType.Any)) { Query condition = query3.Condition; if (condition.StaticType == XPathResultType.Number) { condition = new LogicalExpr(Operator.Op.EQ, new NodeFunctions(Function.FunctionType.FuncPosition, null), condition); } q = new BooleanExpr(Operator.Op.AND, condition, q); input = query3.qyInput; } if (((props & Props.PosFilter) != Props.None) && (input is DocumentOrderQuery)) { input = ((DocumentOrderQuery) input).input; } if (this.firstInput == null) { this.firstInput = input as BaseAxisQuery; } bool flag2 = (input.Properties & QueryProps.Merge) != QueryProps.None; bool flag3 = (input.Properties & QueryProps.Reverse) != QueryProps.None; if ((props2 & Props.HasPosition) != Props.None) { if (flag3) { input = new ReversePositionQuery(input); } else if ((props2 & Props.HasLast) != Props.None) { input = new ForwardPositionQuery(input); } } if (flag && (this.firstInput != null)) { if (flag2 && ((props & Props.PosFilter) != Props.None)) { input = new FilterQuery(input, q, false); Query qyInput = this.firstInput.qyInput; if (!(qyInput is ContextQuery)) { this.firstInput.qyInput = new ContextQuery(); this.firstInput = null; return new MergeFilterQuery(qyInput, input); } this.firstInput = null; return input; } this.firstInput = null; } return new FilterQuery(input, q, (props2 & Props.HasPosition) == Props.None); }