I do something like this (gmail code) to register all the views in an
assembly with the correct service type:
Container.Register(
AllTypes.Pick()
.FromAssembly(assembly)
.If(c => c.FullName.EndsWith("View") &&
selectViewService(c) != null)
.WithService.Select((type, baseType) => new[]
{selectViewService(type)})
.Configure(x => x.LifeStyle.Transient)
);
private static Type selectViewService(Type type)
{
var result = type.GetInterfaces()
.Where(t => t.IsGenericType == false)
.Where(t => t != typeof (IErrorProviderContainer))
.FirstOrDefault(t => t.Namespace.StartsWith("System") ==
false);
return result;
}
On Sat, May 16, 2009 at 12:50 AM, Jonathon Rossi <[email protected]> wrote:
> I'm not sure I understand.
>
> Can you provide and example of what you are doing.
>
>
> On Sat, May 16, 2009 at 1:44 PM, <[email protected]> wrote:
>
>> Is there a way. To specify which interface of the ones a class implements
>> to use?
>>
>> Sent via BlackBerry by AT&T
>>
>> ------------------------------
>> *From*: Jonathon Rossi
>> *Date*: Sat, 16 May 2009 13:32:26 +1000
>> *To*: <[email protected]>
>> *Subject*: Re: How to register all classes to first non-generic interface
>> What do you you mean by first non-generic interface? Can you provide an
>> example.
>>
>> Do you mean from the top of the hierarchy, the first class that implements
>> a non-generic interface? What if this class implements more than 1
>> interface.
>>
>> On Sat, May 16, 2009 at 6:36 AM, George Mauer <[email protected]> wrote:
>>
>>>
>>> How do I register All classes in my assembly to their first non-
>>> generic interface?
>>>
>>> Thanks a lot, George
>>>
>>>
>>
>>
>> --
>> Jono
>>
>>
>>
>>
>>
>>
>
>
> --
> Jono
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---