public void DuplicateInstantiation()
        {
            SlowLoader.Reset();

            var container = new BaseResolver(TimeSpan.FromSeconds(10));

            container.ResolveTo <IResolver>(container);

            container.ResolveTo <ILoadSlowly, SlowLoader>();
            container.ResolveTo <INeedLoadSlowly2, NeedSlowly2>();
            container.ResolveTo <INeedLoadSlowly1, NeedSlowly1>();

            var load1 = container.Resolve <INeedLoadSlowly1>();
            var load2 = container.Resolve <INeedLoadSlowly2>();
        }
예제 #2
0
        public async Task DuplicateInstantiation()
        {
            SlowLoader.Reset();

            var container = new BaseResolver(); //TimeSpan.FromSeconds(10));

            container.ResolveTo <IResolver>(container);

            container.ResolveTo <ILoadSlowly, SlowLoader>();
            container.ResolveTo <INeedLoadSlowly2, NeedSlowly2>();
            container.ResolveTo <INeedLoadSlowly1, NeedSlowly1>();


            var load1 = container.ResolveAsync <INeedLoadSlowly1>();
            var load2 = container.ResolveAsync <INeedLoadSlowly2>();

            await load1;
            await load2;
        }