-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExtensions.cs
58 lines (53 loc) · 2.21 KB
/
Extensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//*****************************************************************************
// Extension.cs - Helper class having various extension methods used in this
// project
//*****************************************************************************
using System.Collections.Generic;
using System.Linq;
namespace QEngine
{
public static class Extensions
{
/// <summary>
/// Executes where query.
/// </summary>
/// <param name="objects">Objectsto be queried.</param>
/// <param name="condition">where condition.</param>
/// <param name="props">Properties of database (Headder values).</param>
/// <returns>Queried collection.</returns>
public static IQueryable<object> Where(this IQueryable<object> objects, string condition, IEnumerable<string> props)
{
QueryEvaluator qe = new WhereQueryEvaluator(objects, condition, props);
return (IQueryable<object>)qe.Evaluate();
}
/// <summary>
/// Executes select query.
/// </summary>
/// <param name="objects">Objects to be queried.</param>
/// <param name="condition">Select condition.</param>
/// <param name="props">Database properties.</param>
/// <returns>Queried collection.</returns>
public static IQueryable<object> Select(this IQueryable<object> objects, string condition, IEnumerable<string> props)
{
QueryEvaluator qe = new SelectQueryEvaluator(objects, condition, props);
return (IQueryable<object>)qe.Evaluate();
}
/// <summary>
/// Checks if the given string is an operator.
/// </summary>
/// <param name="token">string to be checked.</param>
/// <returns>True if the token is operator otherwise false.</returns>
public static bool IsOperator(this string token)
{
return Operator.IsOperator(token);
}
/// <summary>
/// Checks if the given string is a parenthesis.
/// </summary>
public static bool IsParenthesis(this string token)
{
return sParenthesis.Contains(token);
}
static string[] sParenthesis = new string[] { "(", ")" };
}
}