public bool Contains(float x, float y, ContainsMode mode, out IBaseShape rootShape, out IBaseShape childShape) { rootShape = null; childShape = null; for (int i = 0; i < Children.Count; i++) { if (mode == ContainsMode.Geometry) { if (Children[i].Geometry.Contains(x, y)) { rootShape = this.Shape; childShape = Children[i].Shape; return(true); } } else if (mode == ContainsMode.Bounds) { if (Children[i].Bounds.Contains(x, y)) { rootShape = this.Shape; childShape = Children[i].Shape; return(true); } } else { return(false); } } return(false); }
public static Expression <Func <TEntity, IEnumerable <TItem> > > BuildWhereContainsExpression <TEntity, TItem, TProperty>( Expression <Func <TEntity, IEnumerable <TItem> > > collectionAccessorExpression, Expression <Func <TItem, TProperty> > propertyExpression, ICollection <TProperty> collection, ContainsMode containsMode, int cachableLevel = 20) where TItem : class { if (collectionAccessorExpression == null) { throw new ArgumentNullException(nameof(collectionAccessorExpression)); } // x.values Expression collectionAccessor = collectionAccessorExpression.Body; // y => y.property == value op y.property == value2 ... Expression <Func <TItem, bool> > innerExpression = BuildContainsExpression(propertyExpression, collection, containsMode, cachableLevel); // x.values.Where(y => y.property == value op y.property == value2 ..) MethodCallExpression memberCall = Expression.Call(null, GetGenericMethodInfo <TItem>("Where", 2), collectionAccessor, innerExpression); // x => x.values.Where(y => y.property == value op y.property == value2 ..) return(Expression.Lambda <Func <TEntity, IEnumerable <TItem> > >(memberCall, collectionAccessorExpression.Parameters)); }
public bool Contains(float x, float y, ContainsMode mode) { if (mode == ContainsMode.Geometry) { return(Geometry.Contains(x, y)); } else if (mode == ContainsMode.Bounds) { return(Bounds.Contains(x, y)); } return(false); }
public bool Contains(float x, float y, ContainsMode mode, out IBaseShape rootShape, out IBaseShape childShape) { rootShape = null; childShape = null; for (int i = 0; i < _renderer._rootNodes.Count; i++) { if (_renderer._rootNodes[i].Contains(x, y, mode, out rootShape, out childShape)) { return(true); } } return(false); }
public static bool Contains(this IInterval self, int index, ContainsMode mode = ContainsMode.NON_STRICT) { var s = self.ToInterval(); if (mode == ContainsMode.NON_STRICT) { return(s.Start <= index && index <= s.End); } else { return(s.Start < index && index < s.End); } }
/// <summary> /// Converts all wildcard modes to WildCardRight and all non wildcard modes to Default /// </summary> private ContainsMode SingleWordContainsMode(ContainsMode containsMode) { switch (containsMode) { case ContainsMode.WildcardRight: case ContainsMode.AnyWordWildcardRight: case ContainsMode.AllWordsWildcardRight: case ContainsMode.FreeText: return(ContainsMode.WildcardRight); default: return(ContainsMode.Default); } }
public static bool Contains(this IInterval self, IInterval other, ContainsMode mode = ContainsMode.NON_STRICT) { var s = self.ToInterval(); var o = other.ToInterval(); if (mode == ContainsMode.NON_STRICT) { return(s.Start <= o.Start && o.End <= s.End); } else { return(s.Start < o.Start && o.End < s.End); } }
public static bool IsAfter(this IInterval self, IInterval other, ContainsMode mode = ContainsMode.NON_STRICT) { var s = self.ToInterval(); var o = other.ToInterval(); if (mode == ContainsMode.NON_STRICT) { return(s.Start >= o.End); } else { return(s.Start > o.End); } }
private static IEnumerable <Interval <T> > RemoveCoveredEnumerator <T>(this SortedIntervals <T> intervals, ContainsMode mode = ContainsMode.NON_STRICT) { IInterval <T> current = null; foreach (var interval in intervals) { if (current == null) { current = interval; } else if (!current.Contains(interval, mode)) { yield return(interval); current = interval; } } }
public static SelectQuery WhereColumnContains(this SelectQuery query, string leftTableAlias, string leftField, string text, ContainsMode mode = ContainsMode.Default) { query.WhereFilters.WhereColumnContains(leftTableAlias, leftField, text, mode); return(query); }
public static Expression <Func <TEntity, bool> > BuildContainsExpression <TEntity, TProperty>( Expression <Func <TEntity, TProperty> > propertyExpression, ICollection <TProperty> collection, ContainsMode containsMode, int cachableLevel = 20) where TEntity : class { if (propertyExpression == null) { throw new ArgumentNullException(nameof(propertyExpression)); } if (collection == null) { throw new ArgumentNullException(nameof(collection)); } if (!(propertyExpression.Body is MemberExpression)) { throw new ArgumentException( "Property expression should be correct and type of property and collection should be equals. When property types is nullable, collection type also shoud be nullable.", nameof(propertyExpression)); } ParameterExpression parameterExpression = propertyExpression.Parameters[0]; var memberExpression = (MemberExpression)propertyExpression.Body; if (collection.Count > cachableLevel) { return(containsMode == ContainsMode.In ? CreateContainsExpression <TEntity, TProperty>(parameterExpression, memberExpression, collection) : CreateNotContainsExpression <TEntity, TProperty>(parameterExpression, memberExpression, collection)); } return(containsMode == ContainsMode.In ? CreateOrExpression <TEntity, TProperty>(parameterExpression, memberExpression, collection) : CreateAndExpression <TEntity, TProperty>(parameterExpression, memberExpression, collection)); }
public static IQueryable <TEntity> ApplyContainsExpression <TEntity, TProperty>(this IQueryable <TEntity> source, Expression <Func <TEntity, TProperty> > propertyExpression, ICollection <TProperty> collection, ContainsMode containsMode, int cachableLevel = 20) where TEntity : class { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (!collection.Any()) { if (containsMode == ContainsMode.In) { throw new Exception($"${nameof(collection)} must not be empty"); } else { return(source); } } Expression <Func <TEntity, bool> > expression = BuildContainsExpression(propertyExpression, collection, containsMode, cachableLevel); return(source.Where(expression)); }
public static WhereFilterCollection WhereColumnContains(this WhereFilterCollection query, string leftTableAlias, string leftField, string text, ContainsMode mode = ContainsMode.Default) { query.Add(new ColumnContainsWhereFilter() { LeftColumn = new Column(leftTableAlias, leftField), ContainsMode = mode, Text = text }); return(query); }
public static WhereFilterCollection WhereColumnContains(this WhereFilterCollection query, Table leftTable, string leftField, string text, ContainsMode mode = ContainsMode.Default) { query.WhereColumnContains(leftTable.Alias, leftField, text, mode); return(query); }
/// <summary> /// Filter out the intervals that are entirely covered by another interval, if provided /// condition is satisfied. The condition's first parameter is the covering interval, /// the second one is the covered interval. If the condition function returns `true` the /// covered interval will be removed. /// </summary> public static SortedIntervals <T> RemoveCovered <T>(this SortedIntervals <T> intervals, Func <T, T, bool> condition, ContainsMode mode = ContainsMode.NON_STRICT) { return(new SortedIntervals <T>(RemoveCoveredEnumerator(intervals, condition, mode))); }
public static SortedIntervals <T> IntersectingWith <T>(this SortedIntervals <T> intervals, IEnumerable <IInterval> others, ContainsMode mode = ContainsMode.NON_STRICT) { return(new SortedIntervals <T>(intervals.AsEnumerable().IntersectingWith(others, mode))); }
/// <summary> /// Filter out the intervals that are entirely covered by another interval. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="intervals"></param> /// <returns></returns> public static SortedIntervals <T> RemoveCovered <T>(this SortedIntervals <T> intervals, ContainsMode mode = ContainsMode.NON_STRICT) { return(new SortedIntervals <T>(RemoveCoveredEnumerator(intervals, mode))); }