Registering Generic Interface to Closing Types

134 views
Skip to first unread message

Keith

unread,
Dec 15, 2009, 10:52:16 AM12/15/09
to Autofac
Is it possible to register a generic interface so that it will
automatically wire up to its closing types. For example, in
StructureMap, you can do this:

Scan(x =>
{
x.ConnectImplementationsToTypesClosing(typeof
(IScreen<>));
});

This basically scans the assembly and wires up all closed types to the
Open Generic so if I have this:

public class TestScreen : IScreen<Test>

it would automatically give me TestScreen when I request IScreen<Test>

Nicholas Blumhardt

unread,
Dec 16, 2009, 4:25:51 PM12/16/09
to aut...@googlegroups.com
Hi Keith,

We don't have anything exactly equivalent, but Autofac2's RegisterAssemblyTypes() could be used as a basis for implementing it without too much work.

Cheers,
Nick

2009/12/16 Keith <krou...@gmail.com>

--

You received this message because you are subscribed to the Google Groups "Autofac" group.
To post to this group, send email to aut...@googlegroups.com.
To unsubscribe from this group, send email to autofac+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/autofac?hl=en.



Alex Meyer-Gleaves

unread,
Dec 20, 2009, 4:42:04 AM12/20/09
to Autofac
Hi Keith,

I decided to take a look at this and wrote a blog post about it. It
covers handling the scenario you described.

http://alexmg.com/post/2009/12/19/Registering-open-generic-interface-types-in-Autofac.aspx

Cheers,

Alex.

On Dec 17, 7:25 am, Nicholas Blumhardt <nicholas.blumha...@gmail.com>
wrote:


> Hi Keith,
>
> We don't have anything exactly equivalent, but Autofac2's
> RegisterAssemblyTypes() could be used as a basis for implementing it without
> too much work.
>
> Cheers,
> Nick
>

> 2009/12/16 Keith <krouss...@gmail.com>


>
> > Is it possible to register a generic interface so that it will
> > automatically wire up to its closing types. For example, in
> > StructureMap, you can do this:
>
> > Scan(x =>
> >            {
> >                x.ConnectImplementationsToTypesClosing(typeof
> > (IScreen<>));
> >            });
>
> > This basically scans the assembly and wires up all closed types to the
> > Open Generic so if I have this:
>
> > public class TestScreen : IScreen<Test>
>
> > it would automatically give me TestScreen when I request IScreen<Test>
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Autofac" group.
> > To post to this group, send email to aut...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > autofac+u...@googlegroups.com<autofac%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages