Ejemplo n.º 1
0
            public MemberInfo VisitConstructor(EmitConstructor constructor, TypeBuilder parent)
            {
                var constructorBuilder = parent.DefineConstructor(
                    ReflectionMethodAttributes.ToMethodAttributes(constructor.Visibility, false, false, false, false, constructor.IsStatic),
                    constructor.IsStatic ? CallingConventions.Standard : CallingConventions.HasThis,
                    constructor.Parameters.Select(x => (Type)x.ParameterType).ToArray());

                return(constructorBuilder);
            }
Ejemplo n.º 2
0
            public MemberInfo VisitMethod(EmitMethod method, TypeBuilder parent)
            {
                var methodBuilder = parent.DefineMethod(
                    method.Name,
                    ReflectionMethodAttributes.ToMethodAttributes(method.Visibility, method.IsAbstract, method.IsSealed, method.IsVirtual, false, method.IsStatic),
                    method.ReturnType,
                    method.Parameters.Select(x => (Type)x.ParameterType).ToArray());

                var emitMethodBuilder = (EmitMethodBuilder)method;

                emitMethodBuilder.Compile();

                var il = methodBuilder.GetILGenerator();

                GenerateIl(il, emitMethodBuilder.Il);

                return(methodBuilder);
            }