Пример #1
0
        /// <summary>
        /// 添加标签属性时的触发函数.用于设置自身的某些属性值
        /// </summary>
        /// <param name="name"></param>
        /// <param name="item"></param>
        protected override void OnAddingAttribute(string name, Attribute item)
        {
            switch (name)
            {
            case "from":
                VariableExpression ve = item.Value as VariableExpression;
                if (ve == null && this.OwnerDocument.DocumentConfig.CompatibleMode)
                {
                    ve = ParserHelper.CreateVariableExpression(this.OwnerTemplate, item.Text);
                }
                this.From = ve;
                break;

            case "item":
                this.Item = ParserHelper.CreateVariableIdentity(this.OwnerTemplate, item.Text);
                break;

            case "index":
                this.Index = ParserHelper.CreateVariableIdentity(this.OwnerTemplate, item.Text);
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// 输出表达式的原字符串数据
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder buffer = new StringBuilder();

            buffer.Append(this.VariableId.ToString());

            VariableExpression exp = this;

            while (exp != null)
            {
                if (!string.IsNullOrEmpty(exp.FieldName))
                {
                    buffer.Append(".");
                    buffer.Append(exp.FieldName);
                    if (exp.IsMethod)
                    {
                        buffer.Append("()");
                    }
                }
                exp = exp.NextExpression;
            }
            return(buffer.ToString());
        }