botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Overriding IPostToBot

Open mephisto83 opened this issue 10 years ago • 4 comments

How do I override the IPostToBot interface without having to duplicate the Conversation Class. The Conversation Class has a static constructor which doesn't give any opportunities for overriding implementations setup in Autofac. The DialogModule and DialogModule_MakeRoot are both sealed classes, so I can't alter how the implementations of the interfaces are added to Autofac. So, how can I override the implementation of IPostToBot?

mephisto83 avatar Aug 02 '16 10:08 mephisto83

There are a few places where we customize the Autofac container. There is no need to derive a class from the DialogModule, you can simply override previous registrations after registering the DialogModule. Here is an example where we use the framework code from a console application:

https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Tests/FormTest/Program.cs#L101

willportnoy avatar Aug 02 '16 15:08 willportnoy

I made an error in my original request. Instead of IPostToBot, I meant to say IBotToUser. Is the answer still the same?

mephisto83 avatar Aug 03 '16 05:08 mephisto83

Yes, the answer is the same - IBotToUser is even a simpler case:

https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Tests/FormTest/Program.cs#L118

willportnoy avatar Aug 03 '16 17:08 willportnoy

I'm going to close this issue, but feel free to open a new issue for further discussions.

willportnoy avatar Aug 09 '16 21:08 willportnoy