c# - When are Property Imports Satisfied? -
when property imports satisfied? thought satisfied before constructor, properties initialized before constructor runs, following example shows importedclass
null in constructor.
i know can resolve using importingconstuctor; sake of understanding when property imports satisfied.
public myclass { [import] public importedclass importedclass {get;set;} public myclass() { //imported class null @ point, nothing can done here. } }
an object cannot manipulated before constructor being called. mef provides solution problem though, interface called ipartimportssatisfiednotification
public myclass : ipartimportssatisfiednotification { [import] public importedclass importedclass {get;set;} public myclass() { //imported class null @ point, nothing can done here. } public void onimportssatisfied() { //importedclass set @ point. } }
about actions mef takes set imports; first calls constructor, sets properties, calls notification method.
Comments
Post a Comment