#region COPYRIGHT
//
//     THIS IS GENERATED BY TEMPLATE
//     
//     AUTHOR  :     ROYE
//     DATE       :     2010
//
//     COPYRIGHT (C) 2010, TIANXIAHOTEL TECHNOLOGIES CO., LTD. ALL RIGHTS RESERVED.
//
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace System.Text.Template
{
    public class VariableExpression : Expression
    {
        private readonly string _Variable;

        public VariableExpression(string variable)
        {
            _Variable = variable;
        }

        public override ValueExpression Evaluate(ITemplateContext context)
        {
            IValueType valueType;
            if (context.TryGetValue(this._Variable, out valueType))
            {
                return new ValueExpression(valueType);
            }
            else
            {
                return new ValueExpression(null, typeof(object));
            }
        }

        public override string ToString()
        {
            return _Variable;
        }

        public string Variable
        {
            get { return _Variable; }
        }
    }
}
