Access to TweetinviContainer

Jun 9, 2015 at 4:36 PM
Edited Jun 9, 2015 at 4:38 PM
Hi linvi,

Thank you for an excellent product.

My use case is to show Tweets on a screen during a theatre production. To make sure Tweets are shown fairly, I want the Tweets to keep track of how many times they have been shown. To do this, I've extended Tweetinvi.Logic.Tweet as follows:
    public class CountableTweet: Tweetinvi.Logic.Tweet
        public int ShowCount { get; set; }
I understand that, with AutoFac, I should be able to override the registration of Tweetinvi.Logic.Tweet with CountableTweet as follows (because AutoFac resolves to the most recently-registered component for an interface):
*TweetinviContainer*.RegisterType<ITweet, CountableTweet>();
However, I cannot do this as TweetInviContainer keeps the underlying AutoFac container private, and only exposes its Resolve<T> method:
public static class TweetinviContainer
        private static readonly ITweetinviContainer _container;

        static TweetinviContainer()
            _container = new AutofacContainer();

        public static T Resolve<T>()
            return _container.Resolve<T>();
Is there any way to get access to the container without using Reflection?

Jun 9, 2015 at 5:54 PM
Hi Matt,

Thank you for your feedback I greatly appreciate it.

Concerning your question. First of all I think I would personally create an Adapter (GOF Design Patterns) and add you property to the class in question.

But I can understand that some people might want to make their life easier by registering their own classes.
I will find a solution to do that for you and get back to you when it is done.

Please note that the registration can be done only once. So you won't be able to dynamically changed the type/class registration.

Please find the work item here.
Voting on it will allow you to know when the task has been completed.

Jun 9, 2015 at 8:49 PM

This is now implemented and will be released as part of Tweetinvi

Marked as answer by linvi on 6/9/2015 at 12:50 PM
Jun 9, 2015 at 9:21 PM
You're joking?! That was amazingly quick work, thanks!
Jun 9, 2015 at 10:05 PM
Please read the following documentation. It describes how you will be able to setup Tweetinvi to return your class.

Use your classes with Tweetinvi

Marked as answer by linvi on 6/9/2015 at 2:05 PM
Jun 11, 2015 at 11:59 AM
This works perfectly. Thank you again!