コード例 #1
0
        /// <summary>
        /// Configures all injections.
        /// </summary>
        /// <param name="obj"></param>
        private static void ConfigureInjections(ConfigurationExpression configuration)
        {
            configuration.For<IRepository<UserDto>>().HttpContextScoped().Use<Repository<UserDto>>();
            configuration.For<IUserRepository>().HttpContextScoped().Use<UserRepository>(); // this is necessary if we would like to use EF for example and make sure no 2 threads will access one DbContext.

            // For demo purposes, Im using a single source throughout the whole app.
            configuration.For<IFeedSource>().Singleton().Use((() =>
                {
                    var source = new FeedSource<SimpleNewsGator>();
                    source.Subscribe(new FeedDispatcher(new FeedItemHub()));
                    source.Start();
                    return source;
                }));
        }