locked
Notification between parts in different assemblies RRS feed

  • Question

  • I have two assemlies and both have parts. I then load the assemblies in the PortalBase example. How do I make the parts in assembly 1 notify of an even in assembly 2 without modifying the portal base sample. There are posts of notification between parent and child parts but in my case there is no parent - child.

     

     

    Thanks

     

    Thursday, August 30, 2007 8:28 PM

Answers

  • You can use OwningManager property to do this. For example I played with adding StockNews part and Weather part to the portal and executing the following code from Weather part:

     

    Code Snippet

    IPart part = ((PartNavigationItem)OwningManager.NavigationModel[0]).AssociatedPart;

    IStockNewsPartViewContract contract = (IStockNewsPartViewContract)part.GetContract(typeof(IStockNewsPartViewContract));

    //and you can start calling the connection points via the contract

    contract.UpdateNews.Execute(null);

     

     

    In this example my WeatherPart had to take dependency to StockNewsPart assembly to be able to work with IStockNewsPartViewContract. Alternatively you could cast IPart object to some interface you know it implements and only take dependency to the assembly that interface originates from.

    Thanks for the good question, one possible conclusion would be that there should be a way to define Contract objects intepdendenly from the Part's so that they could be packaged into some common assembly.

    Friday, August 31, 2007 6:15 AM

All replies

  • You can use OwningManager property to do this. For example I played with adding StockNews part and Weather part to the portal and executing the following code from Weather part:

     

    Code Snippet

    IPart part = ((PartNavigationItem)OwningManager.NavigationModel[0]).AssociatedPart;

    IStockNewsPartViewContract contract = (IStockNewsPartViewContract)part.GetContract(typeof(IStockNewsPartViewContract));

    //and you can start calling the connection points via the contract

    contract.UpdateNews.Execute(null);

     

     

    In this example my WeatherPart had to take dependency to StockNewsPart assembly to be able to work with IStockNewsPartViewContract. Alternatively you could cast IPart object to some interface you know it implements and only take dependency to the assembly that interface originates from.

    Thanks for the good question, one possible conclusion would be that there should be a way to define Contract objects intepdendenly from the Part's so that they could be packaged into some common assembly.

    Friday, August 31, 2007 6:15 AM
  •  

    Hi Alex,

     

    Thanks for the info!

     

    It helped my too build one of my examples.

     

    Just curious: where did you find this info?

     

     

    Sunday, September 9, 2007 6:28 PM
  • Thanks Danut, I'm glad it was useful. In this particular example I discovered OwningManager property and realized it could become a bridge between sibling parts.

    Thanks,

    Sunday, September 9, 2007 11:37 PM
  • I've been thinking for many years of a way to build an application that runs 100% without UI. What I mean is that a really look less application should have the parts communicate with each other and each view talk only to its part.

     

    Here is a simple example: you have an app that has a list and a text box. Each time the user selects an item the text box gets populated with the selected item string.

     

    You can do that in the views, in the UI but if the UI has to be totally changed, say from Win Forms to WPF then the behavior needs to be reimplemented, while if it is implemented in the parts and the parts talk to each other then moving from Win Forms to WPF will be simpler and easier.

     

    It is exactly how I used your code example in my application.

     

    Maybe the Acropolis team should consider this and implement a more complex mechanism if needed to have the parts talk to each other without involving the UI at all.

     

    Ah, there is another thing, I’m not sure if it needs to be part of Acropolis: I built a prototype and a few slides with an Abstract Layer that separates the layers in a 3 tier application. I used an Abstract Factory to about polluting the UI and the business code with Web Services specific cod fro example. This Abstract layer makes almost a piece of cake to replace WS with WCF and so on. If it is any interest then I can provide you with the sample and the deck.

     

    Thanks,

     

    Thursday, September 13, 2007 2:26 PM