Friday, April 15, 2011

Feature Builder: SVsServiceProvider missing on IQueryStatusStrategy

I tried to apply context aware visibility on a LaunchPoint. On my experience with VSX I looked around for a BeforeQueryStatus alike method. I found the QueryStatusStrategy and this looked as the hook I was looking for. Using a strategy sounded right. So, made a class in the lib project implementing the IQueryStrategy and created a file with the partial implementation of the LaunchPoint overriding the QueryStrategy property getter/setter. Everything works as expected.

VsLaunchPoint code:

  public partial class VsLaunchPointDynamic : VsLaunchPoint  {    private IQueryStatusStrategy _QueryStatusStrategy;     protected override IQueryStatusStrategy QueryStatusStrategy    {      get {return _QueryStatusStrategy;}      set       {         if (value is DefaultQueryStatusStrategy && _QueryStatusStrategy == null)           _QueryStatusStrategy = new OnlyVisibleOnConfigQueryStrategy();          base.QueryStatusStrategy = value;       }     }   } 

Though, I had some difficulties with implementing the strategy, in that means: I wanted to import the SVsServiceProvider from the MEF context but was not available. Something went wrong with the wiring but I can't place it.

For now, during the execution I can call up the container and resolve the serviceprovider but I realy would like the import to work.

  public class OnlyVisibleOnConfigQueryStrategy : IQueryStatusStrategy  {    [Import]    public SVsServiceProvider ServiceProvider { get; set; }     public QueryStatus QueryStatus(IFeatureExtension feature)    {      //ServiceProvider not available: so use the global service from the Package to fetch the container and      //initialize the serviceprovider via the container      var componentModel = Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel;      ServiceProvider = componentModel.GetService<SVsServiceProvider>();      //...   } } 

I would appreciate if someone could give me a hint on how to wire this up.

Thanks in advance,

Jan


Jan

Source: http://social.msdn.microsoft.com/Forums/en-US/vsarch/thread/eb2ecc4b-f4e0-4f2e-a783-d76d79235f64

top 10 architecture schools shipping container architecture byzantine architecture what is enterprise architecture data architecture

No comments:

Post a Comment