Mike Taulty MIX10 Silverlight Frameworks and Patterns

2,335 views
2,244 views

Published on

Session slides from the MIX10 Silverlight workshop.

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,335
On SlideShare
0
From Embeds
0
Number of Embeds
20
Actions
Shares
0
Downloads
27
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mike Taulty MIX10 Silverlight Frameworks and Patterns

  1. 1. Silverlight 4frameworks, patterns<br />Mike Taulty<br />Microsoft Ltd<br />@mtaulty<br />mtaulty@microsoft.com<br />http://mtaulty.com<br />
  2. 2. capabilities<br />need to know some or all of this depending on what you’re building<br />
  3. 3. beyond capabilities<br />*lots of other Silverlight frameworks, <br />libraries, patterns out there – sorry if I missed your favorite<br />
  4. 4. where are we?<br />ASP.NET Client Application Services<br />WCF Data Services<br />WCF RIA Services<br />navigation<br />search<br />extensible applications with MEF<br />
  5. 5. ASP.NET Client App Services<br />ASP.NET services available to Silverlight clients<br />ASP.NET<br />membership<br />roles<br />profiles<br />no specific client libraries here, just add a <br />reference and make the call<br />
  6. 6. enough hot air, do a demo<br />ASP.NET Services from Silverlight<br />
  7. 7. where are we?<br />ASP.NET Client Application Services<br />WCF Data Services<br />WCF RIA Services<br />navigation<br />search<br />extensible applications with MEF<br />
  8. 8. RESTful services (in general)<br />HTTP Request<br />URL<br />Resources<br />VERB<br />Res 1<br />GET<br />Payload<br />Res 2<br />POST<br />PUT<br />Res 3<br />XML<br />JSON<br />DELETE<br />Res 4<br />XML<br />JSON<br />HTTP Response<br />Status<br />Payload<br />
  9. 9. odata<br />Open Data Protocol ( odata)<br />www.odata.org<br />published under the Open Specification Promise<br />Extends the AtomPub standard to add<br />an addressing scheme<br />a mechanism for schema<br />alternate representation – JSON<br />handling for concurrent updates<br />handling for batched requests<br />
  10. 10. WCF Data Services ( “Astoria” )<br />http://server/customers(‘alfki’)/Orders?$top=20<br />WCF Data Services<br />Libraries<br />DataModel<br /><ul><li>EntityFramework
  11. 11. LINQ to SQL
  12. 12. Custom</li></ul>request metadata<br />LINQ Query<br />generated proxy code<br />metadata<br />.NET OData Implementation<br />WCF Data Services<br />Libraries<br />Windows Azure Storage<br />Java<br />PHP<br />SharePoint<br />WebSphere<br />Atom<br />implementation of odata<br />for the client and the server<br />“Other” OData Implementations<br />
  13. 13. enough hot air, do a demo<br />WCF Data Services from Silverlight<br />
  14. 14. WCF Data Services<br />oData – There’s a Feed for That<br />oData – How to Create a Feed for That<br />To learn about OData go to Pablo/Mike’s talks<br />Tuesday 11.30am<br />Lagoon L<br />Tuesday 3pm<br />Breakers H<br />( check 2 B sure )<br />
  15. 15. where are we?<br />ASP.NET Client Application Services<br />WCF Data Services<br />WCF RIA Services<br />navigation<br />search<br />extensible applications with MEF<br />
  16. 16. WCF RIA Services<br />DomainService<br />Stateless CRUD + App Logic<br />class PlateViewDomainService<br />IQueryable<Restaurant> GetRestaurants()<br />IQueryable<Restaurant> SearchRestaurant(string)<br />void AddRestaurant(Restaurant)<br />Validation and authorization rules,<br /> Application workflows, …<br />Data Model<br />class Restaurant<br />DomainContext<br />Stateful view + Bindable Data<br />class PlateViewDomainService<br />EntityList<Restaurant> Books { get }<br />EntityQuery<Restaurant> GetRestaurantQuery()<br />EntityQuery<Restaurant> SearchRestaurantQuery(string)<br />class Restaurant<br />Data members + Validation<br />Data Model +<br />Metadata +<br />Shared Code<br />Services<br />Rich Internet Application<br />Presentation<br />Logic<br />Data Access Layer<br />App<br />Logic<br />Network<br />DomainContext<br />Data<br />Service<br />DB<br />Under the covers infrastructure<br />Note: Slide stolen from Brad Abrams<br />
  17. 17. WCF RIA Services<br />WCF RIA Services (fka .NET RIA Services)<br />You’re building an application<br />You’re responsible for both server and client deep in business logic and semantics<br />WCF Data Services (fka “Astoria”)<br />You’re exposing/acquiring data<br />You control one side or the other, not both<br />CRUD among arbitrary producers / consumers logic and semantics are invisible<br />NB: Slide stolen from Brad Abrams<br />
  18. 18. enough hot air, do a demo<br />WCF RIA Services<br />
  19. 19. WCF RIA Services<br />Developing with WCF RIA Services<br />Quickly & Effectively<br />To learn about WCF RIA Services go to Nikhil Kothari’s talk<br />Tuesday 1:30pm<br />Lagoon H<br />( check 2 B sure )<br />
  20. 20. where are we?<br />ASP.NET Client Application Services<br />WCF Data Services<br />WCF RIA Services<br />navigation<br />search<br />extensible applications with MEF<br />
  21. 21. navigation<br />Page<br />Frame displays a Page<br />Page<br /><UserControl><br /> <Frame <br /> Source=“authors.xaml”/><br />authors.xaml<br />navigation between pages<br />call Frame.Navigate() or set the Source property<br />or use a HyperlinkButton ( NavigateUri/TargetName )<br />navigation history<br />call Frame.[Can]Go[Back()/Forward()]<br />books.xaml<br />
  22. 22. navigation<br />Page<br />Frame displays a Page<br />Page<br /><UserControl><br /> <Frame <br /> Source=“authors.xaml”/><br />authors.xaml<br />navigation can integrate with the browser<br />enables hyperlinking into Silverlight content<br />requires a browser!<br />requires a hidden iframe on the hosting page<br />for top levelFrames not nested frames<br />books.xaml<br />
  23. 23. navigation<br />navigate: http://booksite/default.aspx#/authors/steinbeck<br />navigate: /authors/steinbeck<br />Frame<br />UriMapper<br />ContentLoader<br />Asynchronously turns the URI into a Page or UserControl<br />
  24. 24. enough hot air, do a demo<br />Navigation Framework in Silverlight 4<br />
  25. 25. where are we?<br />ASP.NET Client Application Services<br />WCF Data Services<br />WCF RIA Services<br />navigation<br />search<br />extensible applications with MEF<br />
  26. 26. search<br />search engines visiting a page with Silverlight<br />read robots.txt and sitemap<br />read/index the page title<br />read/index the <meta name=“description”/><br />read/index the surrounding HTML( if any )<br />will not read XAP or dynamic Silverlight content<br />approach<br />alternate content in the <object/> tag<br />for both search engines & down-level clients<br />
  27. 27. enough hot air, do a demo<br />offering alternate content to search<br />note – I stole this demo, it comes from the WCF RIA Services Code Gallery and is called “Silverlight Store”<br />
  28. 28. WCF RIA Services<br />Search Engine Optimization for MS Silverlight<br />To learn more about SEO go to Brad Abrams’ talk<br />Wednesday 12.00<br />Lagoon B<br />( check 2 B sure )<br />
  29. 29. where are we?<br />ASP.NET Client Application Services<br />WCF Data Services<br />WCF RIA Services<br />navigation<br />search<br />extensible applications with MEF<br />
  30. 30. extensible applications with MEF<br />the Managed Extensibility Framework<br />“an extensible framework for composing applications from a set of loosely-coupled parts discovered and evolving at run-time“ (mike)<br />versions<br />.NET Framework shipping with Silverlight 4 <br />.NET Framework 4 shipping with VS 2010<br />Silverlight 3 & .NET Framework V3.5 Sp1 ( from source on CodePlex )<br />
  31. 31. essential MEF<br />import<br />(e.gDebuggerVisualizer)<br />export<br />(e.gDebuggerVisualizer)<br />Component<br />(e.g. Visual Studio)<br />Component<br />(e.g. XML Visualizer)<br />MEF Composition Engine<br />MEF discovers exports via catalogs<br />several “in box” catalogs plus many extensibility points<br />supports available exports changing at runtime<br />and/or can be handed component instances<br />
  32. 32. one application of MEF<br />initial, small download<br />MyApp.xap<br />Extras.xap<br />additional functionality <br />
  33. 33. enough hot air, do a demo<br />the Managed Extensibility Framework<br />
  34. 34. MEF<br />Silverlight Optimization & <br />Extensibility with MEF<br />To really learn about MEF go along to Glenn Block’s talk<br />Tuesday, 3.35pm<br />Lagoon B<br />( check 2 B sure )<br />
  35. 35. where are we?<br />ASP.NET Client Application Services<br />WCF Data Services<br />WCF RIA Services<br />navigation & search<br />extensible applications with MEF<br />Model View ViewModel (MVVM)<br />
  36. 36. why MVVM?<br />View<br />Silverlight client<br />web<br />data<br />
  37. 37. why MVVM?<br />needs to be designable<br />“where does the DisplayDetail flag go?” <br />Data/<br />Service<br />Layer<br />View<br />(e.g. Person Master/Details)<br />Model<br />(e.g. PeopleModel)<br />Code<br />XAML<br />Person<br />Business<br />Layer<br />View<br />model<br />needs to be testable and maintainable<br />Silverlight client<br />
  38. 38. why MVVM?<br />Open to techniques like<br />dependency injection,<br />mocking to aid testability<br />ViewModel is the View’s<br />DataContext.<br />Bind to data, commands<br />ViewModel<br />Designers & Design<br />Tools like XAML so<br />maximize its use<br />View<br />(e.g. Person Master/Details)<br />bridges the gap<br />Model<br />(e.g. PeopleModel/Person)<br />XAML<br />Code<br />Hard to test this<br />code without UI so <br />minimize/remove<br />pure “Data”<br />pure “Display”<br />
  39. 39. commands<br />ICommandseparates UI from functionality<br />No ICommand implementation in Silverlight 4 but some controls make use of ICommand<br />No need for the Button to be aware of the code that handles this Command<br />
  40. 40. triggers, actions, behaviors<br />Blend team’s simple concepts -> powerful results<br />attach/detach yourself to/from<br />any DependencyObject<br />Trigger = START SOMETHING<br />Action == DO SOMETHING<br />Behavior == GET OUT OF JAIL FREE<br />
  41. 41. triggers, actions, behaviors<br />In the Blend SDK<br />Microsoft.Expressions.Interactions.dll<br />System.Windows.Interactivity.dll<br />On CodePlex(expressionblend.codeplex.com)<br />Expression.Samples.Interactivity.dll<br />and lots more out there<br />e.g. Expression Gallery<br />Actions<br />Triggers<br />Behavors<br /><ul><li>KeyTrigger
  42. 42. TimerTrigger
  43. 43. DataEventTrigger
  44. 44. DataTrigger
  45. 45. MouseGestureTrigger
  46. 46. PropertyChangedTrigger
  47. 47. StateChanged
  48. 48. MouseEventTrigger
  49. 49. StoryboardCompletedTrigger
  50. 50. CallMethod
  51. 51. ChangePropertyAction
  52. 52. InvokeCommandAction
  53. 53. CallDataMethod
  54. 54. InvokeDataCommand
  55. 55. SetDataProperty
  56. 56. GoToStateAction
  57. 57. GoToNextState
  58. 58. GoToPreviousState
  59. 59. ListBoxAddOne
  60. 60. ListBoxRemoveOne
  61. 61. ListBoxRemoveThisItem
  62. 62. RemoveElementAction
  63. 63. PauseMedia
  64. 64. PlayMedia
  65. 65. RewindMedia
  66. 66. SetProperty
  67. 67. StopMedia
  68. 68. TogglePlayPauseMedia
  69. 69. ShowMessageBox
  70. 70. HyperlinkAction
  71. 71. PlaySoundAction
  72. 72. ControlStoryboardAction
  73. 73. ClippingBehavior
  74. 74. DataStateBehavior
  75. 75. DataStateSwitchBehavior
  76. 76. FluidBindBehavior
  77. 77. FluidMoveBehavior
  78. 78. MouseDragElementBehavior</li></li></ul><li>MVVM<br />“Main View”<br />Binds to MainViewModel<br />( surfaces enumerable Views )<br />“Filter View”<br />Binds to FilteredProductsViewModel<br />“Products View”<br />Binds to FilteredProductsViewModel<br />( surfaces enumerable ProductViewModel )<br />“Product View”<br />Binds to ProductViewModel<br />
  79. 79. enough hot air, do a demo<br />MVVM, commands and actions<br />
  80. 80. MEF<br />Understanding the MVVM Pattern<br />Build your own MVVM Framework<br />Laurent Bugnion & <br />Rob Eisenberg<br />Monday 2pm<br />Monday 3.30pm<br />Lagoon DEF<br />( check 2 B sure )<br />
  81. 81. resources<br />www.silverlight.tv<br />www.silverlight.net<br />
  82. 82. feedback<br />
  83. 83. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.<br />The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.<br />

×