dependency injection - Enterprise Library - Get value from ParameterValue Expression -
i trying convert enterprise library typeregistration constructorparameters collection of key/value pair (a hashtable or idictionary in general).
the constructorparameters property ienumerableof(parametervalue) problem how extract values each parametervalue object.
every parametervalue object contains type , expression.
for ex. if parametervalue contains: "eventloggingenabled = false" can key (which eventloggingenabled) using expression.member.name can't find way value (which "false").
any thoughts?
have looked @ implementation of unitycontainerconfigurator? if don't want use unity, can see how type registration stuff handled there , adapt windsor api.
you don't need code raw parametervalue class , poke through lambda expressions. there 3 subclasses:
- constantparametervalue
- containerresolvedparameter
- containerresolvedenumerableparameter
the constantparametervalue gives value directly .value property. containerresolvedparameter used when value of parameter needs injected container, , containerresolvedenumerableparameter used when have collection needs injected. every instance of parametervalue 1 of these types.
so, should try cast each one, , switch based on actual type. there's utility base class, parametervaluevisitor, lets implement visitor pattern on parametervalues make code cleaner.
so, i'd drop picking through lambdas - don't need it. implement visitor pull out information need using base class, pre-digested information available in concrete classes. @ unitycontainerconfigurator example of how done.
Comments
Post a Comment