c# - Replace all references to variable in CodeDOM -


i have code-tree generated codedom serializes code similar this:

myclass  {     myclass()      {         this.thepropertyfield = 1;     }      private int thepropertyfield;     int theproperty      {         { return this.thepropertyfield; },          set { this.thepropertyfield = value; }     } } 

the class built xsd.

now want delete private backing-fields , invoke method within getters , setters. works fine, - backing-fields deleted - have replace occurences of private backingfield thepropertyfield property theproperty.

i thought looping statements within constrcutor:

var ctor = type.members.oftype<codeconstructor>().firstordefault(); if (ctor != null) {     var statements = ctor.statements.cast<codestatement>(); } 

but know don´t know further how remove statements references backing-field , add 1 references property instead.


Comments