#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 ValueExpression<T> : ValueExpression
    {
        public ValueExpression(T value)
            : base(value, typeof(T))
        {
        }

        public new T Value
        {
            get { return (T)base.Value; }
        }
    }

    public class ValueExpression : Expression, IValueType
    {
        private Type _Type;
        private object _Value;

        public ValueExpression(IValueType valueType)
            : this(valueType.Value, valueType.Type)
        {
        }

        public ValueExpression(object value, Type type)
        {
            _Value = value;
            _Type = type;
            if (_Type == typeof(object) && _Value != null)
            {
                _Type = _Value.GetType();
            }
        }

        #region ITypeValue Members

        public Type Type
        {
            get { return _Type; }
            set { _Type = value; }
        }

        public object Value
        {
            get
            {
                return _Value;
            }
            set
            {
                _Value = value;
            }
        }

        #endregion

        public override ValueExpression Evaluate(ITemplateContext context)
        {
            return this;
        }

        public override string ToString()
        {
            return Value.ToString();
        }
    }
}
