コード例 #1
0
        private void GenerateConstructor()
        {
            _ctor = _result.DefineConstructor(MethodAttributes.Public,
                                              CallingConventions.Standard, new Type[] { });
            var ctorBuilder = new ILBuilder(_ctor.GetILGenerator());

            ctorBuilder.LoadArg(0);
            ctorBuilder.Call(objectCtor);
            ctorBuilder.DeclareLocal(typeof(Type));
            ctorBuilder.LoadToken(_model);
            ctorBuilder.Call(getTypeFromHandle);
            ctorBuilder.SetLoc(0);

            GenerateCtorInit(ctorBuilder);
            ctorBuilder.Return();
        }
コード例 #2
0
        private static void GenerateGetValue(Type model, TypeBuilder builder, TinyMember info, Type memberType)
        {
            var method = builder.DefineMethod("GetValue", CtMethodAttr,
                                              objectType, new Type[] { objectType });
            var processor = new ILBuilder(method.GetILGenerator());

            processor.DeclareLocal(objectType);
            processor.LoadArg(1).Cast(model);
            processor.GetMember(info);
            if (memberType.IsValueType)
            {
                processor.Box(memberType);
            }
            processor.SetLoc(0);
            processor.LoadLoc(0);
            processor.Return();
        }
コード例 #3
0
		private static void GenerateGetValue(Type model, TypeBuilder builder, TinyMember info, Type memberType)
		{
			var method = builder.DefineMethod("GetValue", CtMethodAttr, 
				objectType, new Type[]{objectType});
			var processor = new ILBuilder(method.GetILGenerator());

			processor.DeclareLocal(objectType);
			processor.LoadArg(1).Cast(model);
			processor.GetMember(info);
			if (memberType.IsValueType)
			{
				processor.Box(memberType);
			}
			processor.SetLoc(0);
			processor.LoadLoc(0);
			processor.Return();
		}