/// <summary>
        /// Compiles a DynamicMethodState and returns a delegate.
        /// </summary>
        /// <typeparam name="R">The return type of the expression</typeparam>
        /// <typeparam name="C">The type of the function class</typeparam>
        /// <param name="methodState">The serialized version of a method on the functionClass</param>
        /// <returns>CompiledCode&lt;R, C&gt; - a delegate that calls the compiled expression</returns>
        public CompiledCode <R, C> GetDelegate <R, C>(DynamicMethodState methodState)
        {
            ExecuteExpression <R, C> methodDelegate = null;

            //get delegate factory
            IExpressionDelegateFactory delegateFactory = new ExpressionDelegateFactory(m_language);

            if (methodState != null && methodState.codeBytes != null)
            {
                //get delegate from factory
                methodDelegate = delegateFactory.CreateExpressionDelegate <R, C>(methodState);
            }

            //return an eval delegate based on the delegate from the factory
            return(new CompiledCode <R, C>(methodDelegate));
        }
        /// <summary>
        /// Compiles an expression and returns a DynamicMethodState
        /// </summary>
        /// <typeparam name="R">The return type of the expression</typeparam>
        /// <typeparam name="C">The type of the function class</typeparam>
        /// <param name="expression">Expression to evaluate</param>
        /// <returns>DynamicMethodState - serialized version of the compiled expression</returns>
        public DynamicMethodState GetMethodState <R, C>(string expression)
        {
            DynamicMethodState methodState;

            //get delegate factory
            IExpressionDelegateFactory delegateFactory = new ExpressionDelegateFactory(m_language);

            //check the function class type to be sure it can be inherited
            Type functionType = typeof(C);

            if (!functionType.IsClass || functionType.IsSealed)
            {
                throw new ApplicationException("Function Type must be a class that is not sealed.");
            }

            //the implementation of the compiler requires an empty constructor
            ConstructorInfo[] infos = functionType.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            bool hasEmptyConstructor = false;

            foreach (ConstructorInfo info in infos)
            {
                if (info.GetParameters().Length == 0 && info.IsStatic == false && info.IsPrivate == false)
                {
                    hasEmptyConstructor = true;
                }
            }

            if (!hasEmptyConstructor)
            {
                throw new ApplicationException("Function Type must be have a parameterless constructor defined.");
            }

            //get the method state
            methodState = delegateFactory.CreateExpressionMethodState <R, C>(expression);

            return(methodState);
        }