ASP.NET AJAX Client Library Question And Answer Series – Question 2
Question: How does Register Class and initializeBase copy child methods into place?
This question is probably referring to a warning I give in most discussions regarding calling initializeBase in the constructor function in an implementing class. In the following screenshot, CallIt.Components.Employee inherits from CallIt.Components.Person. The important thing to note from this example is the call to initializeBase in the constructor.
- Call the call function of the base
- Set the prototype of the implementing class to the base
- Set the constructor of the newly set prototype back to the implementing class (it will be pointing to the base)
ASP.NET AJAX Client Libraries do not follow this pattern, however. Essentially, our libraries copy the implementations from base classes to implementing classes. In my WebCasts, I mention how the call to initializeBase is instrumental in this implementation. Let’s examine… The first thing to look at is the Type.prototype.resolveInheritance function in the Client Libraries below. It is clear that this is the code where the members are copied from base to implementing class.
Now, if you look at the Type.prototype.resolveInheritance implementation, you will note that it calls resolveInheritance. If you fail to make this call, under most circumstances, the base members will not be copied to the implementing class.
If you have a question you would like to add to the list, please email me at email@example.com.