1 / 25

Realizacja aplikacji internetowych

Realizacja aplikacji internetowych. MVVM, Prism i inni. MVC, MVP. MVVM. Anemiczny model ?. MVVM. Model. services. MVVM czytanki. http://www.codeproject.com/Articles/100175/Model-View-ViewModel-MVVM-Explained. Tradycyjna aplikacja. Widok 1. Widok 2. Widok 1. Widok 2. Widok 2.

tender
Télécharger la présentation

Realizacja aplikacji internetowych

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Realizacja aplikacji internetowych MVVM, Prism iinni

  2. MVC, MVP

  3. MVVM Anemiczny model ?

  4. MVVM Model services

  5. MVVM czytanki • http://www.codeproject.com/Articles/100175/Model-View-ViewModel-MVVM-Explained

  6. Tradycyjnaaplikacja Widok 1 Widok 2 Widok 1 Widok 2 Widok 2 Widok 2 Widok 2 Widok 2 Widok 2 Widok 2

  7. MVVM Widok 1 Widok 1 Model(e) i serwisy Widok 2 Widok 2 Model Widoku Model Widoku Widok 2 Widok 2 Widok 2 Widok 2 Model Widoku Widok 2 Widok 2 Model Widoku

  8. Prism • 2.X • 4.0 – WPF 4.0, SL4.0 • 4.1 – WPF 4.0, SL5.0 • 4.5 – WPF 4.5, SL5.0 Podstawowepojęcia: • Shell • Bootstapper • Moduł • Region • Widok

  9. Prism – architekturaaplik.

  10. Prism – bootstrapper • Inicjalizacja : • Aplikacji • Serwisówinfrastukturalnych (core services) • Serwisówaplikacji

  11. Prism – bootstrapper • UnityBootstrapper / MefBootstrapper • Core services: • IModuleManager, IModuleCatalog, IModuleInitializer, IRegionManager, IEventAggregator, ILoggerFacade, IServiceLocator

  12. Prism – shell • Główneokno/strona • Anlogia do masterpage • Obejmujeregiony • Tworzony w Bootstrapperze (wstrzykiwany z Unity/MEF)

  13. Prism – Region “placeholder” dladynamicznegokontentu Adaptery:

  14. Prism – Wstrzykiwaniewidoków • Kodpobiera (np. z RegionManagera) referencję do regionu, tworzyiwstrzykujewidok IRegion region = regionManager.Regions["MainRegion"]; varordersView = container.Resolve<OrdersView>(); region.Add(ordersView, "OrdersView"); region.Activate(ordersView);

  15. Prism – Odkrywaniewidoków • Definiujemy w RegionViewRegistryrelacje Region vs. TypWidkokuipodczastworzeniaregionuautomatycznietworzony jest odpowiedniwidok this.regionManager.RegisterViewWithRegion("MainRegion“, () => this.container.Resolve<EmployeeView>());

  16. Prism – Region adapter-y ContentControlRegionAdapter – dlakontrolekSystem.Windows.Controls.ContentControlipochodnych SelectorRegionAdapter - dlapochodnychklasSystem.Windows.Controls.Primitives. (np. System.Windows.Controls.TabControl control). ItemsControlRegionAdapter – dlakobtrolektypuSystem.Windows.Controls.ItemsControlipochodnych TabControlRegionAdapter– (tylko SL) Custom adapter np. dla stack pannel mappings.RegisterMapping(typeof(StackPannel), new StackPannelRegionAdapter());

  17. Prism – custom adapter protected override void Adapt(IRegion region, ContentControlregionTarget) { region.Views.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add) foreach(FrameworkElements element in e.NewItems) { regionTarget.Children.Add(element) ; } // handle removing of elemts }; }

  18. Prism – Komunikacja • Komendy • DelegateCommand – zwyklelokalna, używadelegatów, niewymagahandlerów • DelegateCommand – bezparamerów • DelegateCommand<T> - wymagaparametrów (XAML-> commandParameter=…) • CompositeCommand - zwykleglobalna, służy do składaniakomend, składaniekomend (dzialaCanExecute -> wszystkiemusząbyćdostępne) • Shared Services • EventAggregator • Region Context

  19. Prism – Komendy • DelegateCommand – zwyklelokalna, używadelegatów, niewymagahandlerów • DelegateCommand – bezparamerów • DelegateCommand<T> - wymagaparametrów (XAML-> commandParameter=…) • CompositeCommand - zwykleglobalna, służy do składaniakomend, składaniekomend (dzialaCanExecute -> wszystkiemusząbyćdostępne)

  20. Prism – EventAggregator

  21. EA – subskrypcja eventAggregator.GetEvent<TickerSymbolSelectedEvent>().Subscribe(ShowNews); • wątki: • PublisherThread • BackgroundThread • UIThread. eventAggregator.GetEvent<TickerSymbolSelectedEvent>().Subscribe(ShowNews, ThreadOption.UIThread); • Filtrowanie: fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == _customerId);

  22. EA – publikacja, rezygnacja z s. • Publikacja: EventAggregator.GetEvent<TickerSymbolSelectedEvent>().Publish(“STOCK0”); • Rezygnacja z subskrypcji: FundAddedEventfundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false); fundAddedEvent.Unsubscribe(subscriptionToken);

  23. Region Context • Obiektwspółdzielonyprzezhostaiwidoki w regionie • Widoczny w XML i w kodzie • Wymagadependancy object • To nie to samo co DataContext Definicja: RegionManager.Regions["Region1"].Context = employeeId; Odwołanie • ObservableObject<object> viewRegionContext = RegionContext.GetObservableContext(this); Lub • cal:RegionManager.RegionContext="{Binding Path=SelectedEmployee.EmployeeId}"

  24. Prism linki • HomePage http://compositewpf.codeplex.com/ • HOL - http://msdn.microsoft.com/en-us/library/gg405475%28v=pandp.40%29.aspx • Dokumentacja http://msdn.microsoft.com/en-us/library/gg406140.aspx

  25. Inne MVVM • Caliburn Micro • Knockout (JavaScript framework) • I inne… 

More Related