Multiple strategies to build an object

Nov 21, 2009 at 8:42 PM

Hello all,

First of all, nice piece of work this is. Enterprise library as a whole and specifically Unity.

Now, the questions from my team.

We've been trying to implement a way to build objects that are supplied by different sources using a predefined sequence.

For example we can have a local object that can be built through the regular type mapping mechanism provided by Unity and Object Builder.

On the other hand we can have an object that lives on a remote location, for example on a old Web Service (.asmx).

For this scenario we've implemented an extension that uses a BuilderStrategy that, through a BuildPlanPolicy invokes our internal method that can create, at runtime, the proxy to that Web Service and return the constructed object.

Now we are migrating those old Web Services to a WCF Services.

We can implement the same scenario, described earlier, working for WCF services using a BuilderStrategy that, through a BuildPlanPolicy invokes an internal method that, using the channelfactory and the regular WCF configuration, returns the constructed object.

However it seems that we can't have 2 BuildPlanPolicies working at the same time on the same container.

 

What i really need is to do something like the following:

1-  if the object is local the Unity Framework will take care of that object and build it

2- if the object is not local do the following:

1- try to build the object from the configured WCF endpoint as described above

2 - if the previous step was not successful, then try build the object from the old Web Service (.asmx) using the scenario also described above.

 

We've some doubts about the way strategies and policies fit together and how they are evaluated at runtime.

Is there any documentation on this?

We would like some directions, since we are kind of stuck on this

 

Thanks in advance

Filipe Lima