Developing Line-of-Business
Applications with Microsoft Silverlight
                                 Nuno Godinho
                         Nuno.Godinho@sapo.pt
Agenda
 Introduction
 Recommended Pattern
 Communications
 Beyond the Browser
 Extensibility
 Q&A
About Me
Nuno Filipe Godinho
Independent Consultant

Mail:    Nuno.Godinho@sapo.pt
         Nuno.Godinho@itech4all.com

Blogs:   http://pontonetpt.com/blogs/nunogodinho
         http://xamlpt.com/blogs/nunogodinho
         http://weblogs.asp.net/nunogodinho
         http://msmvps.org/blogs/nunogodinho

Twitter: @NunoGodinho
Agenda
 Introduction
 Recommended Pattern
 Communications
 Beyond the Browser
 Extensibility
 Q&A
Introduction
Problem Statement

   Problems
    ◦   N-Tier
    ◦   Controls
    ◦   Rich Text Support
    ◦   Multi-language Support
    ◦   Customer Devices Interaction
    ◦   Communications
    ◦   Extensibility
    ◦   Offline Support
    ◦   Interoperability
Introduction
Challenges using N-Tier applications

    LoB applications use data that needs to flow across tiers

    Created and used through basic CRUD operations

    In an internet application, there is a trust boundary between
     the client and the mid-tier server

    Important to have a well defined and secured resources that
     are available to the client tier and also what operations are
     permitted
Introduction
Challenges using N-Tier applications

    The validation needs to run on Client and On Server as well as
     on Mid-Tiers

    Common validation across the tiers

    Services that may be shared with other applications
Introduction
Vision and Goals

    Simplify RIA-style application development
     ◦ n-tier is hard, and un-natural
     ◦ Focus on data-driven apps

    Bring ASP.NET-style productivity to RIA development
     ◦ Building blocks for data, security, etc.
     ◦ Focus on scenarios
Introduction
Value Propositions

    Focus on data in an end-to-end manner

    A unified story for client and server development

    A prescriptive framework that targets key scenarios, and
     leads the common developer to a pit of success
Introduction
Value Propositions

    Simplify application development across tiers and trust
     boundary
     ◦ Provides a set of tools to build the multiple tiers of an application
       together
     ◦ Application logic remains aware of tier and trust boundaries
     ◦ Uses the end-to-end flow of data and metadata described earlier
     ◦ Code generation and shared code
         Enhance the experience by providing multiple choices for sharing
          logic while respecting tier and trust boundaries
Introduction
A Unified Story for Client and Server

    Client is an extension of the server
                                                                                  Service
    A single logical application
                          Rich Internet Application
        Browser                                 Application



                            Presentation             App            Data Access
        HTML                Network
                               Logic                Logic              Layer


                                                                                       DB
                                                              Services




                                                      Other Applications
Introdution
Value Propositions

    Define and support a pattern for exposing a set of operations
     on resources

    DomainService
     ◦ Define a set of operations on resources

    Framework and Tools
     ◦ Collaborate to generate code for a corresponding client-tier
     ◦ Services for authentication and user settings can be used out-of-the
       box
Introduction
A Prescriptive Pattern
                                                                                   Services




                                Rich Internet Application


 Presentation    Domain        Network
                                               Domain        App    Data Access
    Logic        Context                       Service      Logic      Layer

                    Under the covers infrastructure




                                                                              DB
Introduction
A Single Pattern that Scales and Grows

     Support for multiple presentation tiers and data access technologies

.NET Clients                                                       Databases
Silverlight, WPF                                                   ADO.NET,
                                                                   ORMs (LTS, EF, …)

Standards
Clients
JavaScript                                                        CLR
                                           App                    Lists/Objects
                                          Logic                   Repository
     Server                                                       (nHibernate, …)
     Rendering
     HTML, SEO,
     Printing, …                                                  Services
                                                                  REST/SOAP
                   SOAP,                 Unit Test                (Azure, …)
 Services           XML,                  Code
                   JSON,
 WCF
                   Binary
Line-of-Business Application
Agenda
 Introduction
 Recommended Pattern
 Communications
 Beyond the Browser
 Extensibility
 Q&A
Recommended Pattern
Recommended Pattern
MVVM

   Why?
    ◦ Separation of concerns
    ◦ Better Workflow between Developer and Designer
    ◦ Easier Testability

   Why not MVC?
    ◦ We need to have access to the Code-Behind and MVC doesn’t support
      that, only Code-Behind Pattern does, but doesn’t delivers easy
      separation of concerns
Recommended Pattern
MVVM




                Display data in Controls


                UI Friendly Entities, UI State, Actions


                Entities representing data
MVVM Implementation in Silverlight
Agenda
 Introduction
 Recommended Pattern
 Communications
 Beyond the Browser
 Extensibility
 Q&A
Communication
Unified Programming Model




   ASMX & WSE                                     .NET Remoting


      Interop                                      Extensibility
    with other                                       Location
Platforms & WS-*                                  transparency


        Attribute-                            Message-
         Based                                 Oriented
      Programming           REST / HTTP      Programming
                            Programming
        Enterprise                           System.Messaging
         Services
                             HTTP Services
Communications
Windows Communication Foundation (WCF)
Communications
WCF RIA Services

    Framework, tools and services with prescriptive pattern for n-
     tier applications
                                             Trust
                                           Boundary
       Web
      Service

                           Data
                         Access     App                App
                                                              View
                          Layer    Logic              Logic
                          (DAL)

  Database
Communications
WCF RIA Services

    Design-time view
                                  Solution (Application)

             Server project                                  Client project

        Entities                                      Entities
                                  Build, reflect
          Data                    & code-gen                            Views
        Access          Domain
                                                      Domain
         Layer          Service
                                                      Context
         (DAL)
Communications
Run-time view (entity lifecycle)

                                      Application

               Web server                                     Silverlight
                                        Query                   Load
           Data
                                        Entities    Domain     Entities
         Access             Domain                                          Views
          Layer             Service                 Context     Submit
                                       Submit
          (DAL)
                                        Results                 Results
Communications
Services

    Authentication
    Roles
    User profile
    All integrate w/ ASP.NET infrastructure
WCF RIA Services
Agenda
 Introduction
 Recommended Pattern
 Communications
 Beyond the Browser
 Extensibility
 Q&A
Beyond the Browser
   Out-of-Browser Applications

   Trusted Applications
Beyond the Browser
Out-of-Browser – Already on Silverlight 3


    Configuration Based

    AppManifest.xml

    Can be enabled in an existing application without rebuilding

    Install option on its right-click menu

    Can run without a network connection
    You can implement network detection and provide offline
     support when a connection is unavailable
Beyond the Browser
Out-of-Browser

    Windowing API

    WebBrowser control

    HtmlBrush

    Notification (aka. Toast)
Beyond the Browser
Trusted Applications



    OOB with elevated privileges

    COM Interop in Windows

    File system access

    Cross-domain networking access

    Full keyboard support in Full-Screen Mode
Beyond the Browser
Agenda
 Introduction
 Recommended Pattern
 Communications
 Beyond the Browser
 Extensibility
 Q&A
Extensibility
   Prism v2

   MEF – Managed Extensibility Framework
Extensibility
Prism v2

    Prism is a set of options
    Use what you want and ignore the rest
     ◦ Example:
        Choose Modules and Commanding, but ignore Event Aggregation
         and Regions
Extensibility
Prism v2

    Prism Technical Concepts
Extensibility
MEF – Managed Extensibility Framework




   A new library in Silverlight 4 for building
    applications that can be incrementally
                   extended.
Extensibility
MEF – Managed Extensibility Framework

                     An Application is built of parts.
Extensibility
MEF – Managed Extensibility Framework



                                          Export it.

                                          Import it.

                                        Compose it.
Extensibility
MEF – Managed Extensibility Framework

    Export it - Metadata
                              [ExportMetadata(“Location”,Location.Top)]
                              [Export(typeof(UserControl))]
                              public class Widget1 : UserControl
                              {
                                            public string Message {
                                              get{return(string) Button.Content;}
                                          set{Button.Content=value;}
                                       }
                              }




 Widget1                     Export
Extensibility
MEF – Managed Extensibility Framework

    Import it - Metadata
                           [Export(typeof(UserControl))]
                           public class MainPage: UserControl
                           {
                                        [ImportMany(typeof(UserControl))]
                                        public IEnumerable<Lazy<UserControl, IWidgetMetadata>
                                        {
                                           get;set;
                                        }
                           }




     Main
                              ImportMany
     Page
MEF – Managed Extensibility Framework
Agenda
 Introduction
 Recommended Pattern
 Communications
 Beyond the Browser
 Extensibility
 Q&A
Nuno Filipe Godinho
Independent Consultant

Mail:   Nuno.Godinho@sapo.pt
        Nuno.Godinho@itech4all.com

Nuno Godinho

  • 1.
    Developing Line-of-Business Applications withMicrosoft Silverlight Nuno Godinho Nuno.Godinho@sapo.pt
  • 2.
    Agenda  Introduction  RecommendedPattern  Communications  Beyond the Browser  Extensibility  Q&A
  • 3.
    About Me Nuno FilipeGodinho Independent Consultant Mail: Nuno.Godinho@sapo.pt Nuno.Godinho@itech4all.com Blogs: http://pontonetpt.com/blogs/nunogodinho http://xamlpt.com/blogs/nunogodinho http://weblogs.asp.net/nunogodinho http://msmvps.org/blogs/nunogodinho Twitter: @NunoGodinho
  • 4.
    Agenda  Introduction  RecommendedPattern  Communications  Beyond the Browser  Extensibility  Q&A
  • 5.
    Introduction Problem Statement  Problems ◦ N-Tier ◦ Controls ◦ Rich Text Support ◦ Multi-language Support ◦ Customer Devices Interaction ◦ Communications ◦ Extensibility ◦ Offline Support ◦ Interoperability
  • 6.
    Introduction Challenges using N-Tierapplications  LoB applications use data that needs to flow across tiers  Created and used through basic CRUD operations  In an internet application, there is a trust boundary between the client and the mid-tier server  Important to have a well defined and secured resources that are available to the client tier and also what operations are permitted
  • 7.
    Introduction Challenges using N-Tierapplications  The validation needs to run on Client and On Server as well as on Mid-Tiers  Common validation across the tiers  Services that may be shared with other applications
  • 9.
    Introduction Vision and Goals  Simplify RIA-style application development ◦ n-tier is hard, and un-natural ◦ Focus on data-driven apps  Bring ASP.NET-style productivity to RIA development ◦ Building blocks for data, security, etc. ◦ Focus on scenarios
  • 10.
    Introduction Value Propositions  Focus on data in an end-to-end manner  A unified story for client and server development  A prescriptive framework that targets key scenarios, and leads the common developer to a pit of success
  • 11.
    Introduction Value Propositions  Simplify application development across tiers and trust boundary ◦ Provides a set of tools to build the multiple tiers of an application together ◦ Application logic remains aware of tier and trust boundaries ◦ Uses the end-to-end flow of data and metadata described earlier ◦ Code generation and shared code  Enhance the experience by providing multiple choices for sharing logic while respecting tier and trust boundaries
  • 12.
    Introduction A Unified Storyfor Client and Server  Client is an extension of the server Service  A single logical application Rich Internet Application Browser Application Presentation App Data Access HTML Network Logic Logic Layer DB Services Other Applications
  • 13.
    Introdution Value Propositions  Define and support a pattern for exposing a set of operations on resources  DomainService ◦ Define a set of operations on resources  Framework and Tools ◦ Collaborate to generate code for a corresponding client-tier ◦ Services for authentication and user settings can be used out-of-the box
  • 14.
    Introduction A Prescriptive Pattern Services Rich Internet Application Presentation Domain Network Domain App Data Access Logic Context Service Logic Layer Under the covers infrastructure DB
  • 15.
    Introduction A Single Patternthat Scales and Grows  Support for multiple presentation tiers and data access technologies .NET Clients Databases Silverlight, WPF ADO.NET, ORMs (LTS, EF, …) Standards Clients JavaScript CLR App Lists/Objects Logic Repository Server (nHibernate, …) Rendering HTML, SEO, Printing, … Services REST/SOAP SOAP, Unit Test (Azure, …) Services XML, Code JSON, WCF Binary
  • 16.
  • 17.
    Agenda  Introduction  RecommendedPattern  Communications  Beyond the Browser  Extensibility  Q&A
  • 18.
  • 19.
    Recommended Pattern MVVM  Why? ◦ Separation of concerns ◦ Better Workflow between Developer and Designer ◦ Easier Testability  Why not MVC? ◦ We need to have access to the Code-Behind and MVC doesn’t support that, only Code-Behind Pattern does, but doesn’t delivers easy separation of concerns
  • 20.
    Recommended Pattern MVVM  Display data in Controls  UI Friendly Entities, UI State, Actions  Entities representing data
  • 21.
  • 22.
    Agenda  Introduction  RecommendedPattern  Communications  Beyond the Browser  Extensibility  Q&A
  • 23.
    Communication Unified Programming Model ASMX & WSE .NET Remoting Interop Extensibility with other Location Platforms & WS-* transparency Attribute- Message- Based Oriented Programming REST / HTTP Programming Programming Enterprise System.Messaging Services HTTP Services
  • 24.
  • 25.
    Communications WCF RIA Services  Framework, tools and services with prescriptive pattern for n- tier applications Trust Boundary Web Service Data Access App App View Layer Logic Logic (DAL) Database
  • 26.
    Communications WCF RIA Services  Design-time view Solution (Application) Server project Client project Entities Entities Build, reflect Data & code-gen Views Access Domain Domain Layer Service Context (DAL)
  • 27.
    Communications Run-time view (entitylifecycle) Application Web server Silverlight Query Load Data Entities Domain Entities Access Domain Views Layer Service Context Submit Submit (DAL) Results Results
  • 28.
    Communications Services  Authentication  Roles  User profile  All integrate w/ ASP.NET infrastructure
  • 29.
  • 30.
    Agenda  Introduction  RecommendedPattern  Communications  Beyond the Browser  Extensibility  Q&A
  • 31.
    Beyond the Browser  Out-of-Browser Applications  Trusted Applications
  • 32.
    Beyond the Browser Out-of-Browser– Already on Silverlight 3  Configuration Based  AppManifest.xml  Can be enabled in an existing application without rebuilding  Install option on its right-click menu  Can run without a network connection  You can implement network detection and provide offline support when a connection is unavailable
  • 33.
    Beyond the Browser Out-of-Browser  Windowing API  WebBrowser control  HtmlBrush  Notification (aka. Toast)
  • 34.
    Beyond the Browser TrustedApplications  OOB with elevated privileges  COM Interop in Windows  File system access  Cross-domain networking access  Full keyboard support in Full-Screen Mode
  • 35.
  • 36.
    Agenda  Introduction  RecommendedPattern  Communications  Beyond the Browser  Extensibility  Q&A
  • 37.
    Extensibility  Prism v2  MEF – Managed Extensibility Framework
  • 38.
    Extensibility Prism v2  Prism is a set of options  Use what you want and ignore the rest ◦ Example:  Choose Modules and Commanding, but ignore Event Aggregation and Regions
  • 39.
    Extensibility Prism v2  Prism Technical Concepts
  • 40.
    Extensibility MEF – ManagedExtensibility Framework A new library in Silverlight 4 for building applications that can be incrementally extended.
  • 41.
    Extensibility MEF – ManagedExtensibility Framework An Application is built of parts.
  • 42.
    Extensibility MEF – ManagedExtensibility Framework Export it. Import it. Compose it.
  • 44.
    Extensibility MEF – ManagedExtensibility Framework  Export it - Metadata [ExportMetadata(“Location”,Location.Top)] [Export(typeof(UserControl))] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 Export
  • 45.
    Extensibility MEF – ManagedExtensibility Framework  Import it - Metadata [Export(typeof(UserControl))] public class MainPage: UserControl { [ImportMany(typeof(UserControl))] public IEnumerable<Lazy<UserControl, IWidgetMetadata> { get;set; } } Main ImportMany Page
  • 46.
    MEF – ManagedExtensibility Framework
  • 47.
    Agenda  Introduction  RecommendedPattern  Communications  Beyond the Browser  Extensibility  Q&A
  • 49.
    Nuno Filipe Godinho IndependentConsultant Mail: Nuno.Godinho@sapo.pt Nuno.Godinho@itech4all.com