-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDCVariableExpressionItem.cs
More file actions
72 lines (65 loc) · 1.86 KB
/
DCVariableExpressionItem.cs
File metadata and controls
72 lines (65 loc) · 1.86 KB
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
/*
都昌数值表达式引擎 DCSoft.Expression
南京都昌信息科技有限公司 2018年 版权所有
公司网址 http://www.dcwriter.cn
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace DCSoft.Expression
{
/// <summary>
/// 变量元素
/// </summary>
[System.Runtime.InteropServices.ComVisible( false )]
public class DCVariableExpressionItem : DCExpressionItem
{
/// <summary>
/// 初始化对象
/// </summary>
public DCVariableExpressionItem()
{
}
private string _Name = null;
/// <summary>
/// 名称
/// </summary>
public string Name
{
get
{
return _Name;
}
set
{
_Name = value;
}
}
/// <summary>
/// 执行表达式,根据上下文获取变量值
/// </summary>
/// <param name="context">上下文对象</param>
/// <returns>变量值</returns>
public override object Eval(IDCExpressionContext context)
{
return context.GetVariableValue(this.Name);
}
/// <summary>
/// 输出调试用字符串
/// </summary>
/// <param name="indentLevel">层次</param>
/// <param name="str">字符串对象</param>
public override void ToDebugString(int indentLevel, StringBuilder str)
{
str.AppendLine(new string(' ', indentLevel * 3) + "VAR:" + this.Name);
}
/// <summary>
/// 返回表示对象的字符串
/// </summary>
/// <returns>字符串</returns>
public override string ToString()
{
return "VAR:" + this.Name;
}
}
}