Scrutor icon indicating copy to clipboard operation
Scrutor copied to clipboard

Getting types just found during Scan

Open dario-l opened this issue 1 year ago • 6 comments

Simply question.

Is there any possibility to take those types just gathered by Scrutor? I do not want to iterate again.

dario-l avatar Sep 29 '23 09:09 dario-l

Hey @dario-l! 👋🏻

Not types specifically added by Scrutor, but you can enumerate the descriptors in the service collection to see which types were added.

khellang avatar Sep 29 '23 14:09 khellang

Hi @khellang Damn, that's a shame. Scrutor scans for all types that I want to register in contaoner but after that I need to run scan/search method again instead of get the result of that scan straight from scrutor. 😞

Something like this could be great addition. 😃

dario-l avatar Oct 10 '23 14:10 dario-l

Hi @khellang again 😃 Just found a solution. This will work?

        var tempServices = new ServiceCollection();

        tempServices.Scan(  );
        
        foreach (var x in tempServices)
        {
            services.Add(x);
        }

dario-l avatar Oct 10 '23 14:10 dario-l

Yes, that will work 👍

khellang avatar Oct 10 '23 14:10 khellang

Great. Thanks 👍🏻

dario-l avatar Oct 10 '23 14:10 dario-l

Set do,not single。 services.Add(tempServices.Scan( )); instead if you can。Never intend to use loop if we don't need。

Hi @khellang again 😃 Just found a solution. This will work?

        var tempServices = new ServiceCollection();

        tempServices.Scan(  );
        
        foreach (var x in tempServices)
        {
            services.Add(x);
        }

xingzuhui avatar Dec 06 '23 20:12 xingzuhui