Prism開発者ガイド-パート9、疎リンクコンポーネント間の相互運用性

目次

  1. はじめに
  2. Prismアプリケーションの初期化
  3. コンポーネント間の依存関係の管理
  4. モジュラーアプリケーション開発
  5. MVVMパターンの実装
  6. 高度なMVVMシナリオ
  7. ユーザーインターフェイスの作成

    1. ユーザーインターフェイスのガイドライン
  8. ナビゲーション
    1. ビューベースのナビゲーション
  9. 疎結合コンポーネント間の相互作用


大規模で複雑なアプリケーションを作成する場合、通常の方法は、機能を個別のモジュールに分離することです。 また、これらのモジュール間の静的リンクの数を最小限にすることをお勧めします。 これにより、モジュールを個別に開発、テスト、展開、および更新できます。 これはすべて、モジュールが疎結合の方法で相互作用する必要性につながります。



モジュール間の相互作用のモデルを構築する場合、特定のシナリオにどのアプローチを適用するかを知るために、アプローチ間の違いを知る必要があります。 Prismライブラリは、次のアプローチを提供します。







コマンドの使用( Solution commanding



ボタンをクリックするなどのユーザージェスチャに応答する必要がある場合、およびアプリケーションロジックに基づいてコントロールの可用性を制御する場合は、コマンドを使用します。



WPFは、ボタンやメニュー項目などのコマンドを呼び出すコントロールを、キーボードフォーカスを持つ現在の項目に関連付けられたコマンドハンドラーに関連付けるのに適したルーティングコマンド( RoutedCommand



)を提供します。



ただし、複合アプリケーションのシナリオでは、イベントハンドラーは、ビジュアルツリーに関連する要素がないか、フォーカスのないプレゼンテーションモデルであることがよくあります。 このようなシナリオをサポートするために、Prismには、コマンドの実行時にデリゲートを呼び出すことができるDelegateCommand



クラスと、複数のコマンドを1つに結合できるCompositeCommand



クラスが用意されています。 これらのクラスは、コマンド処理をビジュアルツリーの上下にルーティングするRoutedCommand



クラスとは異なります。 ビジュアルツリーでコマンドを開始し、より高いレベルで処理できます。



CompositeCommand



クラスはICommand



インターフェイスを実装しているため、コントロールにバインドできます。 CompositeCommands



クラスは、いくつかの子コマンドに関連付けることができます。 CompositeCommand



実行すると、子コマンドも実行されます。



CompositeCommand



クラスはアクティベーションをサポートします。 CanExecuteChanged



イベントCanExecuteChanged



、それ自体がこのイベントを生成します。 その後、関連付けられたコントロールはCanExecute



メソッドを呼び出します。 CompositeCommand



CanExecute



メソッドを呼び出して、すべての子コマンドをポーリングします。 コマンドがfalse



返す場合、 CompositeCommand



false



返すため、コントロールが非アクティブになります。



Prismライブラリベースのアプリケーションでは、 SaveSave All、 Cancelなど、アプリケーション全体で意味のあるグローバルCompositeCommand



コマンドをシェルで定義できます 。 モジュールは、ローカルチームをこれらのグローバルチームに登録し、実行に参加できます。



WPFルーティングイベントルーティングイベント )およびルーティングコマンドルーティングコマンド )に関する注意。

ルーティングイベントは、要素ツリーのさまざまな場所にある複数のハンドラーで処理できるという点で、通常のイベントとは異なります。 WPFルーティングイベントは、ビジュアルツリーのアイテム間でメッセージを運びます。 ビジュアルツリーにない要素は、これらのコマンドを処理できません。 ルーティングされたイベントは、ビジュアルツリーの要素間の通信に使用できます。これは、イベントデータがルートの各要素に保存されるためです。 1つの要素がこのデータ内の何かを変更する可能性があり、この変更はルート内の次の要素で使用できます。



WPFルーティングイベントは、次の場合に使用できます。共通のルート要素に共通のハンドラーを設定する場合、または独自のコントロールクラスを作成する場合。





委任コマンドの作成



デリゲートコマンドを作成するには、ビューモデルのコンストラクターでDelegateCommand



型のフィールドを作成および初期化し、 ICommand



型のプロパティを通じてアクセスできるようにする必要があります。



 public class ArticleViewModel : NotificationObject { private readonly ICommand _showArticleListCommand; public ArticleViewModel(INewsFeedService newsFeedService, IRegionManager regionManager, IEventAggregator eventAggregator) { _showArticleListCommand = new DelegateCommand(this.ShowArticleList); } public ICommand ShowArticleListCommand { get { return _showArticleListCommand; } } }
      
      





ご注意

めったに使用されないコマンドの場合、プロパティのget



メソッドで直接DelegateCommand



を「怠lazに」作成することが理にかなっています。



 public class ArticleViewModel : NotificationObject { private readonly ICommand _showArticleListCommand; public ArticleViewModel(INewsFeedService newsFeedService, IRegionManager regionManager, IEventAggregator eventAggregator) { } public ICommand ShowArticleListCommand { get { return _showArticleListCommand ?? ( _showArticleListCommand = new DelegateCommand(this.ShowArticleList) ); } } }
      
      







複合コマンドの作成



複合コマンドを作成するには、ビューモデルのコンストラクターでCompositeCommand



型のフィールドを作成および初期化し、 ICommand



型のプロパティを介してアクセス可能にする必要があります。



 public class MyViewModel : NotificationObject { private readonly CompositeCommand _saveAllCommand; public ArticleViewModel(INewsFeedService newsFeedService, IRegionManager regionManager, IEventAggregator eventAggregator) { _saveAllCommand = new CompositeCommand(); _saveAllCommand.RegisterCommand(new SaveProductsCommand()); _saveAllCommand.RegisterCommand(new SaveOrdersCommand()); } public ICommand SaveAllCommand { get { return _saveAllCommand; } } }
      
      







グローバルにアクセス可能なチームを作成する



通常、グローバルにアクセス可能なコマンドを作成するには、 DelegateCommand



インスタンス、またはCompositeCommand



を作成し、静的クラスを介して使用できるようにします。



 public static class GlobalCommands { public static CompositeCommand MyCompositeCommand = new CompositeCommand(); }
      
      





次に、モジュールは子チームをグローバルチームに関連付けます。



 GlobalCommands.MyCompositeCommand.RegisterCommand(command1); GlobalCommands.MyCompositeCommand.RegisterCommand(command2);
      
      





ご注意

コードのテスト容易性を向上させるために、メディエーションクラスを使用して、グローバルにアクセス可能なコマンドにアクセスし、テストでモックできます。





グローバルにアクセス可能なチームへのリンク



次のコード例は、ボタンをWPFのグローバルコマンドにバインドする方法を示しています。



 <Button Name="MyCompositeCommandButton" Command="{x:Static local:GlobalCommands.MyCompositeCommand}" Content="Execute My Composite Command"> </Button>
      
      





Silverlightはx:static



サポートを提供しないため、Silverlightでボタンをバインドするには、次の手順に従う必要があります。



  1. ビューモデルでは、 public



    クラスを作成して、静的クラスで指定されたコマンドを受け取る必要があります。

     public ICommand MyCompositeCommand { get { return GlobalCommands.MyCompositeCommand; } }
          
          





  2. 通常、ビューモデルはDataContext



    (別のコードファイルで行われます)を介してビューに関連付けられます。

     view.DataContext = model;
          
          





  3. 次のXML名前空間がルート要素に追加されていることを確認します。

     xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Commands;assembly=Microsoft.Practices.Prism"
          
          





  4. 添付のClick.Command



    プロパティを使用して、ボタンをコマンドにバインドします。

     <Button Name="MyCommandButton" prism:Click.Command="{Binding MyCompositeCommand}" Content="Execute MyCommand"/> </Button>
          
          





ご注意

別のアプローチは、コマンドをリソースとしてApplication.Resources



セクションのApp.xamlファイルに保存することです。 その後、ビューでバインドします。



 <Button Name="MyCommandButton" prism:Click.Command="{Binding MyCompositeCommand, Source={StaticResource GlobalCommands}} Content="Execute MyCommand"/> </Button>
      
      







地域のコンテキスト



領域(ホスト)に関連付けられたビューとその領域にあるビューの間でコンテキスト情報を転送する必要がある場合、多くのシナリオがあります。 たとえば、 マスター/詳細スクリプトでは、ビューにはエンティティと、このエンティティに関する追加情報が表示されるリージョンが表示されます。 下の図に示すように、PrismはRegionContext



と呼ばれる概念を使用して、リージョン内のホストとそのリージョンにロードされたビューの間でオブジェクトを転送します。



RegionContextの使用



シナリオに応じて、情報(識別子など)とモデル全体の両方を裏切ることができます。 ビューはRegionContext



を受け取り、変更通知を待つことがあります。 ビューはRegionContext



の値を変更することもできます。 RegionContext



を取得および設定するには、いくつかの方法があります。







ご注意

現在、Prismは、そのビューがDependencyObject



子孫である場合、領域内のビューからRegionContext



を取得することをサポートしています。 ビューがDependencyObject



でない場合(たとえば、データテンプレートを使用してビューモデルを領域に直接追加する場合)、独自のRegionBehavior



クラスを作成して、 RegionContext



をビューオブジェクトに渡すことを検討してください。



DataContext



プロパティについて注意してください。


データコンテキストは、コントロールが親要素からバインドするためのデータソース情報を継承できるようにする概念です。 子要素は、親要素からDataContext



を自動的に継承します。 データはビジュアルツリー全体に広がります。



ビューモデルをSilverlightのビューにバインドする最良の方法は、 DataContext



を使用するDataContext



です。 それが、ほとんどのシナリオで、 DataContext



プロパティを使用してビューモデルを格納する理由です。 このため、疎結合ビュー間の通信メカニズムとしてDataContext



を使用することはお勧めしません。





共有サービス



モジュール間相互作用を実装する別の方法は、共有サービスを使用することです。 モジュールをロードするとき、そのサービスをDIコンテナに追加できます。 通常、サービスは、別のアセンブリにある共通のインターフェイスを介してコンテナから登録および要求されます。 これにより、モジュールは、これらのモジュールへの静的リンクを必要とせずに、他のモジュールが提供するサービスを使用できます。 サービスインスタンスはすべてのモジュールに共通であるため、データを交換してモジュール間でメッセージを送信できます。



Stock Trader RIでは、 MarketモジュールはIMarketFeedService



実装を提供します。 Positionモジュールは、アプリケーションシェルで定義されたDIコンテナを使用してこのサービスを使用します。 IMarketFeedService



他のモジュールでの使用を目的としているため、 StockTraderRI.Infrastructureの一般アセンブリにありますが、その特定の実装は公開されてはならないため、 Marketモジュールで定義され、他のモジュールから独立して変更できます。



これらのサービスがMEFコンテナーにどのようにエクスポートされるかを確認するには、 MarketFeedService.csおよびMarketHistoryService.csファイルを参照してください。 PositionモジュールのObservablePosition



クラスは、コンストラクターでの依存関係注入を通じてIMarketFeedService



サービスを受け取ります。



 [Export(typeof(IMarketFeedService))] [PartCreationPolicy(CreationPolicy.Shared)] public class MarketFeedService : IMarketFeedService, IDisposable { ... }
      
      





ご注意

上記の例に示すように、一部のDIコンテナでは、属性を使用して依存関係を登録できます。 その他には、明示的な登録が必要な場合があります。 このような場合、登録は通常、 IModule.Initialize



メソッドでのモジュールのロード中に行われます。 詳細については、パート4「 モジュール式アプリケーションの開発 」を参照してください。





イベント集約



Prismライブラリは、アプリケーション内の疎結合コンポーネント間の相互運用性のためのメカニズムを提供します。 このメカニズムは、イベント集約サービスとパブリッシャー-サブスクライバーテンプレートに基づいており、 パブリッシャーとサブスクライバーが相互に明示的なリンクなしで対話できるようにします。



EventAggregator



は、マルチキャストパブリッシング/サブスクリプション機能を提供します。 これは、イベントを発行しているパブリッシャーと、このイベントにサブスクライブしているサブスクライバーが複数いる可能性があることを意味します。 EventAggregator



を使用して、複数のモジュール間でイベントを発行したり、コントローラーやプレゼンターなどのビジネスロジックコード間でメッセージを送信したりすることを検討してください。



この例はStock Trader RIです。この場合、[注文を処理]ボタンをクリックすると注文処理が開始されます。 この場合、いくつかのモジュールは、送信を更新するために注文が処理されたことを認識する必要があります。



Prismを使用して作成されたイベントは強く型付けされています。 これは、コンパイル時に型チェックを利用できることを意味します。 EventBase



クラスを使用すると、サブスクライバーまたはパブリッシャーが特定のEventBase



を検出して、イベントのタイプを判別できます。 次の図に示すように、複数のサブスクライバーおよびパブリッシャーが一度に使用できます。



イベント集約



.NET Frameworkのイベントノート。

.NET Frameworkに組み込まれたイベントメカニズムを使用することは、疎結合が必要ない場合にコンポーネントが相互に対話するための最も単純で最も明白な方法です。 .NET FrameworkのイベントはPublish-Subscribeパターンを実装しますが、オブジェクトのイベントをサブスクライブするには、このオブジェクトへの直接参照が必要です。これは、複合アプリケーションでは別のモジュールにあることがよくあります。 その結果、強く結び付けられた設計ができます。 したがって、.NET Frameworkイベントは、モジュール間ではなくモジュール間でのメッセージングに使用する必要があります。



.NET Frameworkイベントを使用する場合、特に静的または長命のオブジェクトのイベントをサブスクライブする非静的または短命のコンポーネントがある場合は、メモリリークを防ぐように非常に注意する必要があります。 サブスクライバーがサブスクリプションのサブスクリプションを解除しない場合、パブリッシャーはそのリンクを保持します。これにより、最初のサブスクライバーがガベージを収集できなくなります。





IEventAggregatorインターフェイス



IEventAggregator



サービスは、 IEventAggregator



インターフェイスを介してコンテナからEventAggregator



れます。 イベントアグリゲーターは、イベントオブジェクトの検出、作成、および保存を行います。



 public interface IEventAggregator { TEventType GetEvent<TEventType>() where TEventType : EventBase; }
      
      





EventAggregator



は、まだ作成されていない場合、最初の要求でイベントオブジェクトを作成します。 パブリッシャーまたはサブスクライバーは、イベントが利用可能かどうかを判断する必要がなくなります。





クラスCompositePresentationEvent



パブリッシャーをサブスクライバーに接続する実際の作業は、 CompositePresentationEvent



クラスによって行われます。 Prismライブラリに含まれるEventBase



クラスの唯一の実装です。 サブスクライバーのリストを維持し、これらのサブスクライバーに送信するイベントを処理します。



CompositePresentationEvent



クラスは汎用であり、ペイロードのタイプの定義が必要です。 これにより、パブリッシャーおよびサブスクライバーは、イベントフックを成功させるための正しい署名をメソッドに提供できます。 次のコードは、 CompositePresentationEvent



クラスの部分的な定義を示しています。



 public class CompositePresentationEvent<TPayload> : EventBase { ... public SubscriptionToken Subscribe(Action<TPayload> action); public SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption); public SubscriptionToken Subscribe(Action<TPayload> action, bool keepSubscriberReferenceAlive) public virtual SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive); public virtual SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive, Predicate<TPayload> filter); public virtual void Publish(TPayload payload); public virtual void Unsubscribe(Action<TPayload> subscriber); public virtual bool Contains(Action<TPayload> subscriber) ... }
      
      







イベントの作成と公開



以下のセクションでは、 IEventAggregator



インターフェイスを使用してCompositePresentationEvent



イベントを作成、発行、およびサブスクライブする方法について説明します。





イベント作成


CompositePresentationEvent , , . TPayLoad . , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .












クラスはCompositePresentationEvent , , . TPayLoad . , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .












CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








 CompositePresentationEvent      ,   ,  . TPayLoad
      
      



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }

.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .












CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








 CompositePresentationEvent      ,   ,  . TPayLoad
      
      



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








 CompositePresentationEvent      ,   ,  . TPayLoad
      
      



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








 CompositePresentationEvent      ,   ,  . TPayLoad
      
      



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








 CompositePresentationEvent      ,   ,  . TPayLoad
      
      



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








 CompositePresentationEvent      ,   ,  . TPayLoad
      
      



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








 CompositePresentationEvent      ,   ,  . TPayLoad
      
      



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








 CompositePresentationEvent      ,   ,  . TPayLoad
      
      



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








 CompositePresentationEvent      ,   ,  . TPayLoad
      
      



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .








CompositePresentationEvent , , . TPayLoad



. , .



, TickerSymbolSelectedEvent



Stock Trader RI . , . , .



public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }





.

, , . Stock Trader RI , StockTraderRI.Infrastructure .







EventAggregator



Publish



. EventAggregator



, , IEventAggregator



.



, TickerSymbolSelectedEvent



.



this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");









, Subscribe



CompositePresentationEvent



. CompositePresentationEvents



. .



, UI. , . , . , .



.





UI

, UI . WPF Silverlight, UI UI.



, . UI, UI. , UI. , UI, Dispatcher



.



CompositePresentationEvent



, UI. , .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }





ThreadOption



:



PublisherThread



. . . BackgroundThread



. .NET Framework. UIThread



. UI.





. , filter



. System.Predicate , , , .



, -, .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);






.

- Silverlight, , ( CompositePresentationEvent



). - , Silverlight. , public , keepSubscriberReferenceAlive



true



, ( ).



- Silverlight, public



, , , ( ).



public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);





.

Subscribe



Microsoft.Practices.Prism.Events.SubscriptionToken



, . , -, , .



.

, . .





( Strong references )

, , , , , . .



, CompositePresentationEvent



. , , CompositePresentationEvent



, . .



, keepSubscriberReferenceAlive



Subscribe



, .



FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);





keepSubscriberReferenceAlive



bool



:



true



, , . , . false



( , ), , . , .





, , , . , TickerSymbolSelectedEvent



, string



, .



public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }









, , , .



, , .



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);





, , . Subscribe



.



FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);









, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .











All Articles