Hi!

 

It would be nice if it would be possible to do something like this:

 

        internal static ComponentRegistration<object>
ConfigurePropertyInjection(this ComponentRegistration
componentRegistration)

        {

            ComponentRegistration<object> result =
componentRegistration.Configuration();

 

            result = result.Properties(pi =>
pi.HasCustomAttribute<InjectAttribute>(), isRequired: true);

            result = result.Properties(pi =>
pi.HasCustomAttribute<InjectOptionallyAttribute>(), isRequired: false);

 

            return result;

        }

 

I've tried it, but the problem is that the first line means that all
properties that would be matched by the second predicate has already been
filtered away... which means that things won't work as I've expected.

 

Maybe I can get around it by using a custom
ComponentModelConstructionContributor, but it would be nice to be able to
do it otherwise. Suggestion: add a new overload for Properties() which
takes a Func<PropertyInfo, SomeCustomType> as parameter. In the CustomType
object, there should be one flag for saying whether the property should be
injected or not, and one flag for saying whether it should be set up using
mandatory or optional injection.

 

Please, let me know if there's already some other (easy) way to get this
done.

 

Best regards,

-- -- -- -- -- -- -- --

PER LUNDBERG Software Engineer
[email protected] <mailto:[email protected]>   www.ecraft.com
<http://www.ecraft.com/> 

tel. +358 (0) 20 759 8687

eCraft Oy Ab, Wolffskavägen 36, FI-65200 Vasa

 

-- 
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.

Reply via email to