Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

New Post: Access to TweetinviContainer

$
0
0
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?

Thanks,
Matt

Viewing all articles
Browse latest Browse all 4126

Trending Articles