Example #1
0
        public void DispatchConstant(Expression e)
        {
            var    const_Val          = ((ConstantExpression)e).Value;
            string codeRepresentation = objectToCode.PlainObjectToCode(const_Val, e.Type);

            //e.Type.IsVisible
            if (codeRepresentation == null)
            {
                var typeclass = e.Type.GuessTypeClass();
                if (typeclass == ReflectionHelpers.TypeClass.NormalType) // probably this!
                {
                    Sink("this");                                        //TODO:verify that all this references refer to the same object!
                }
                else
                {
                    throw new ArgumentOutOfRangeException(
                              "e",
                              "Can't print constant " + (const_Val == null ? "<null>" : const_Val.ToString())
                              + " in expr of type " + e.Type);
                }
            }
            else
            {
                Sink(codeRepresentation);
            }
        }
 public static string PlainObjectToCode(this IObjectToCode it, object val)
 {
     return(it.PlainObjectToCode(val, val == null ? null : val.GetType()));
 }