>>I think you need to use a delegate. Oversimplifing your example (and using C# I'm afraid):
public class ViewPageClass
>> {
>> public void GetPage()
>> {
>> Parser p = new Parser();
>> // Replace default handling.
>> p.handler = SpecificReplaceWithThisContent;
>> bool b = p.ReplaceWithThisContent();
>> }
>>
>> public bool SpecificReplaceWithThisContent()
>> {
>> return false;
>> }
>>
>> }
>> public class Parser
>> {
>> public delegate bool Doit();
>>
>> public Doit handler;
>>
>> public bool ReplaceWithThisContent()
>> {
>> if (handler != null)
>> {
>> return handler();
>> }
>> else
>> {
>> //Do the default handling. E.g:
>> return false;
>> }
>> }
>> }}
So a call to Parser.ReplaceWithThisContent() will actually run the ViewPageClass.SpecificReplaceWithContent()
>
>I think this approach is similar to the one from Denis. Also, later on in this thread, in Message #
1475334, I provided the current approach I am using which is simply about making a public method in the client and calling it from the class. Do you see any downsize in that approach?
Hi,
Guess I hadn't read all of the thread when I replied :-}
Yes, Dennis's approach is essentially the same as mine - but I haven't used VB enough to know whether this is as simple as a straightforward delegate.
The only problem I see with your approach is that the type of loParser.oOriginator must implement the ParseGetContent() method which introduces a restriction (but it's not clear from the code snippet you show why this is even accepted by the compiler). If you use a delegate then the Parser could be used from any type.