Hi Krzysztof, yes, something along the lines of that would probably work, I missed the BasedOn method, or maybe I just thought that it couldn't deal with generic types.
Thanks a lot. 2010/6/23 Krzysztof Koźmic <[email protected]> > Simone - would it be possible to just keep the files in a common namespace > and have > > AllTypes.FromThisAssembly().BasedOn(typeof(IMyComponent<, >)) > .If(Component.IsInSameNamespaceAs<MyComponent>()) > .WithService.AllInterfaces()); > > or would it not cut it for you? > > > On 24/06/2010 1:47 AM, SimoneB wrote: > >> Ok this is what I've come up with, not very clean, honestly. >> >> var serviceType = typeof(IMyComponent<,>); >> var basedOn = typeof(MyComponentBase<,>); >> >> Func<Type, bool> predicate = t => t.IsGenericType&& >> t.GetGenericTypeDefinition() == basedOn; >> >> return AllTypes.FromAssembly(someAssembly) >> .Where(type => type.IsAbstract == false&& >> type.AnyInHierarchy(predicate)) >> .WithService.Select((type, baseType) => >> >> Enumerable.ToEnumerable(serviceType.MakeGenericType(type.FirstInHierarchy(predicate).GetGenericArguments()))); >> >> Where the extension methods on Type have the obvious meaning. >> >> On Jun 23, 5:07 pm, SimoneB<[email protected]> wrote: >> >> >>> Hi, >>> >>> how would I register a component like this: >>> >>> class MyComponent : MyComponentBase<Type1, Type2> {} >>> >>> abstract class MyComponentBase<T1, T2> : IMyComponent<T1, T2> {} >>> >>> interface IMyComponent<T1, T2> {} >>> >>> with service IMyComponent<Type1, Type2> which resolves to MyComponent >>> by convention using the fluent API? >>> >>> >> >> > > -- > 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]<castle-project-users%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/castle-project-users?hl=en. > > -- 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.
