.net - emit Opcodes set field to a value -


i trying dynamic create proxy, im pleying emit. when set field emit need set isdirty field boolan true.

how can ?

property customer {   set   {     this.customername = value;     this.isdirty = true;   } } 

emit code:

 fieldbuilder isdirtyfield = mytypebuilder.definefield("isdirty", typeof(bool), fieldattributes.private);                                                                // define "set" accessor method customername.             methodbuilder custnamesetpropmthdbldr =                 mytypebuilder.definemethod("set_customername",                                            getsetattr,                                            null,                                            new type[] { typeof(string) });          ilgenerator custnamesetil = custnamesetpropmthdbldr.getilgenerator();          custnamesetil.emit(opcodes.ldarg_0);         custnamesetil.emit(opcodes.ldarg_1);         custnamesetil.emit(opcodes.stfld, customernamebldr);          {             custnamesetil.emitwriteline("start isdirty");             ... stuf here             custnamesetil.emitwriteline("end isdirty");          }         custnamesetil.emit(opcodes.ret); 

this code working, long im not trying isdirty field, having spent weekend on this, im trying in forum. thx

// dennis

i believe sequence of il instructions want be

custnamesetil.emit(opcodes.ldarg_0);     // load custnamesetil.emit(opcodes.ldc_i4_1);            // load true (same integer 1) custnamesetil.emit(opcodes.stfld, isdirtyfield); // store isdirty 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -