This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
IsDayOffFunction.cs
75 lines (60 loc) · 1.78 KB
/
IsDayOffFunction.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.Data.Filtering;
namespace DXSample {
public class IsDayOffFunction : ICustomFunctionOperatorBrowsable {
const string FunctionName = "IsDayOff";
static readonly IsDayOffFunction instance = new IsDayOffFunction();
public static void Register()
{
CriteriaOperator.RegisterCustomFunction(instance);
}
public static bool Unregister()
{
return CriteriaOperator.UnregisterCustomFunction(instance);
}
#region ICustomFunctionOperatorBrowsable Members
public FunctionCategory Category
{
get {return FunctionCategory.DateTime; }
}
public string Description
{
get { return "IsDayOff"; }
}
public bool IsValidOperandCount(int count)
{
return count == 1;
}
public bool IsValidOperandType(int operandIndex, int operandCount, Type type)
{
return type == typeof(DateTime);
}
public int MaxOperandCount
{
get { return 1; }
}
public int MinOperandCount
{
get { return 1; }
}
#endregion
#region ICustomFunctionOperator Members
public object Evaluate(params object[] operands)
{
DateTime dt = Convert.ToDateTime(operands[0]);
return dt.DayOfWeek == DayOfWeek.Sunday || dt.DayOfWeek == DayOfWeek.Saturday;
}
public string Name
{
get { return FunctionName; }
}
public Type ResultType(params Type[] operands)
{
return typeof(bool);
}
#endregion
}
}