Exemple #1
0
        internal DynamicILGen CreateDynamicMethod(string methodName, Type returnType, Type[] parameterTypes,
                                                  bool isDebuggable)
        {
            ContractUtils.RequiresNotEmpty(methodName, "methodName");
            ContractUtils.RequiresNotNull(returnType, "returnType");
            ContractUtils.RequiresNotNullItems(parameterTypes, "parameterTypes");

            if (_saveSnippets)
            {
                AssemblyGen   assembly = GetAssembly(isDebuggable, false);
                TypeBuilder   tb       = assembly.DefinePublicType(methodName, typeof(object), false);
                MethodBuilder mb       = tb.DefineMethod(methodName, TypeUtils.PublicStatic, returnType, parameterTypes);
                return(new DynamicILGenType(tb, mb, mb.GetILGenerator()));
            }
            else
            {
                DynamicMethod dm = Helpers.CreateDynamicMethod(methodName, returnType, parameterTypes);
                return(new DynamicILGenMethod(dm, dm.GetILGenerator()));
            }
        }
Exemple #2
0
        internal TypeBuilder DefineType(string name, Type parent, bool preserveName, bool isUnsafe, bool emitDebugSymbols)
        {
            AssemblyGen ag = GetAssembly(emitDebugSymbols, isUnsafe);

            return(ag.DefinePublicType(name, parent, preserveName));
        }