Ejemplo n.º 1
0
        private static Func <ILGenerator, ILGenerator> LookUpForClass2String(Type source, Type destination)
        {
            if (source.IsValueType)
            {
                return(null);
            }
            if (typeof(String) != destination)
            {
                return(null);
            }

            // instance or null is on top of the stack
            return(il => il
                   .Dup()
                   .If(true, x => x
                       .Callvirt(FromLambda.Method <Object, String>(o => o.ToString()))
                       ));
        }
Ejemplo n.º 2
0
        private static Func <ILGenerator, ILGenerator> LookUpForEnum2String(Type source, Type destination)
        {
            if (!source.IsEnum)
            {
                return(null);
            }
            if (typeof(String) != destination)
            {
                return(null);
            }

            // unboxed enum is on top of the stack
            return(il => il
                   .Box(source)
                   .Ldstr("d")
                   .Call(FromLambda.Method <Enum, String, String>((e, f) => e.ToString(f)))
                   );
        }
Ejemplo n.º 3
0
        private static Func <ILGenerator, ILGenerator> LookUpForStruct2String(Type source, Type destination)
        {
            if (!source.IsValueType)
            {
                return(null);
            }
            if (typeof(String) != destination)
            {
                return(null);
            }

            LocalBuilder value;

            // struct is on top of the stack
            return(il => il
                   .DefineLocal(source, out value)
                   .Stloc(value)
                   .Ldloca(value)
                   .Constrained(source)
                   .Callvirt(FromLambda.Method <Object, String>(o => o.ToString()))
                   );
        }