1. XML Configuration<!--we register Hexuobjectpostprocessor in the context object on the Object.xml file--<ObjectId="Hexu"Type="CNBLOGLESSON_4_7.MODEL.PERSON,HRABLL"Init-method="Init"Destroy-method="Destroy"/> <ObjectType="CNBLOGLESSON_4_7.HEXUOBJECTPOSTPROCESSOR,HRABLL"/>2. Codenamespacecnbloglesson_4_7 { Public classHexuobjectpostprocessor:iobjectpostprocessor { Public ObjectPostprocessafterinitialization (ObjectInstancestringobjectName) { if(Objectname.endswith ("Sysdicttypedao")) { returnActivator.CreateInstance (typeof(Sysdicttypedao)); } Console.WriteLine ("I called the Postprocessafterinitialization method of the object post-processor, and the current object is {0}", ObjectName); returninstance; } Public ObjectPostprocessbeforeinitialization (ObjectInstancestringname) {Console.WriteLine ("I called the Postprocessbeforeinitialization method of the object post-processor, and the current object is {0}", name); returninstance; } } }
Spring.net after the processor can be used to switch instances