예제 #1
0
        private ConstructorInfo BuildConstructor(TypeBuilder typeBuilder, NBehavePropertyBuilder nbehaveBuilder)
        {
            ConstructorBuilder constructor = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
            ILGenerator        cil         = constructor.GetILGenerator();

            cil.Emit(OpCodes.Ldarg_0);
            nbehaveBuilder.Instantiate(cil);
            cil.Emit(OpCodes.Ret);

            return(constructor);
        }
예제 #2
0
        override public Type BuildType()
        {
            TypeBuilder typeBuilder = CreateTypeBuilder();

            typeBuilder.AddInterfaceImplementation(typeof(NBehaveMock));

            NBehavePropertyBuilder nbehaveBuilder  = new NBehavePropertyBuilder(typeBuilder);
            PropertyInfo           nbehaveProperty = nbehaveBuilder.Build();

            BuildConstructor(typeBuilder, nbehaveBuilder);
            OverrideMethods(typeBuilder, nbehaveProperty);

            return(typeBuilder.CreateType());
        }
예제 #3
0
        override public Type BuildType()
        {
            TypeBuilder typeBuilder = moduleBuilder.DefineType(type.FullName, TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.AutoClass, null);

            typeBuilder.AddInterfaceImplementation(type);
            typeBuilder.AddInterfaceImplementation(typeof(NBehaveMock));

            NBehavePropertyBuilder nbehaveBuilder  = new NBehavePropertyBuilder(typeBuilder);
            PropertyInfo           nbehaveProperty = nbehaveBuilder.Build();

            BuildConstructor(typeBuilder, nbehaveBuilder);
            ImplementMethods(typeBuilder, nbehaveProperty);

            return(typeBuilder.CreateType());
        }