Beispiel #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);
        }
        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());
        }
Beispiel #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());
        }