I'd like to enhance/mimic the dependency injection done by the object builder to include some custom properties
the standard way is
in mySmartPart.cs
[CreateNew] MyPresenter ABC { .... }
[ServiceDependency] myService XYZ { ... }
in include [MyCustomReferenceAttribute] CustomerObject MyCustomer { .... }
etc.
This can obviously be done after the smartPart is created but i'm guessing ( hoping ? ) there's some place i can hook up some code extension to do the needful instead of rep开发者_如何学Pythoneating the code everyplace !!!
Unity/ObjectBuilder uses a chain of responsibility pattern called its Strategy Chain. You can plugin your own steps in this chain to get some customization out of how Unity/ObjectBuilder does its object construction.
Here's more information about the design of Unity: http://msdn.microsoft.com/en-us/library/cc440939.aspx
My gut says that you are really wanting to replace large parts of Unity. I think this would require you to gut large parts of this strategy chain and replace it with customized versions.
Depending on what you are trying to accomplish, it is possible that simply inheriting your attributes from DependencyResolutionAttribute and just add a strategy to the StrategyChain. Here's how the default strategies are configured (and also a complete list of strategies in use in Unity: http://unity.codeplex.com/SourceControl/changeset/view/39621#427281
I know this is a lot of information, but hopefully this gives you a few directions.
精彩评论