Silverlight project NOTE 2: getting started with Prism and IoC, silverlightprism

Source: Internet
Author: User
Tags javascript extension

Silverlight project NOTE 2: getting started with Prism and IoC, silverlightprism

The project adopts the Prism framework. The following are some preliminary understandings:

 1. Prism

Prism is a MVVM framework for WPF and Silverlight developed by the Microsoft Patterns & Practices Team.

Key Points of Prism:

(1) starter class UnityBootstrapper

Bootstrapper is called at the Silverlight program entrance. during the Run method, Prism will automatically perform initialization, including reading the module information table, creating a module class instance and initializing it (you can also select the OnDemand mode as needed ), and specify the Root View of the entire program in CreatShell.

(2) inherit the IModule interface to initialize the module.

The UnityContainer container (IoC container Unity is used) is passed in the constructor to obtain the container object. The Resolve method of the UnityContainer object needs to be used in a lot to obtain the object associated with the specified object, that is, you can directly use the container object container to obtain the instance or method.

Then, Initialize some module-related initialization tasks in Initialize, such as listening to event messages and performing some work on the interface when loading the module.

(3) Manage RegionManager through the UI

Previously, some initialization work was required on the interface during module initialization. Using the Prism framework, you can easily switch and navigate the UI control.

When the module is initialized, it registers the pages that need to be used. When loading is required, the page can be directly loaded to the specified area.

That is, when the module registers a Page "XXXMainView" during initialization, when listening to Page loading events, it can be loaded to the previously designed Page area "Page Region ".

(4) event aggregation service EventAggregator

Prism provides the event aggregation service EventAggregator, which is more convenient to use than delegate events. You can register events and publish and subscribe them directly. This will be widely used in communication between modules.

Ii. IoC container Unity

IoC is the Inversion of Contro control Inversion. It gives control over the code to the system. For example, the creation of an object and the call of a method are all handed over to Unity for control, unity is also a lightweight, scalable dependency injection container implemented by the Microsoft patterns & practices Team using C #. The advantage of this is to eliminate direct dependencies between modules, abstract-oriented, even interface-oriented programming, facilitates program extension and maintenance.

Use the UnityContainer container object (m_Container and container in the figure) to register the relationship between the object and the object (IDataService and XXXDataService ), you can parse the registered object through the container object anywhere in the program, and then execute the attributes or methods of the registered object,

In addition to EventAggregator, this is another way to communicate between modules.

 

Iii. Benefits of Using Prism and IoC

(1) modular functions: The system is divided into multiple independent modules to facilitate collaborative development by multiple people;

(2) Effectively reduce the program size, add IoC to the modular development mode, and implement interface-oriented programming. Each module performs its own duties, which greatly reduces the number of repeated class libraries referenced by the module and reduces the size of compiled programs, rich clients such as Silverlight increase the loading speed.

(3) the hierarchical logic is clearer and easier to develop;

(4) low coupling between modules. When the module is not updated, it can be unloaded without re-compilation, greatly reducing the Compilation Time.

(5) Enhanced scalability and maintainability.

Therefore, if the system has a certain degree of complexity, it is a good choice to use Prism and IoC for non-Demo or prototype systems.

 


What software is Silverlight20?

Microsoft SilverLight is a cross-browser, cross-customer platform technology that can design, develop, and release network interaction programs with multimedia experience and Rich Interface Application.
SilverLight provides a powerful platform for developing Web applications with professional graphics, audio, and video, enhancing the user experience, therefore, SilverLight attracts the attention of designers and developers. SilverLight also provides powerful tools to improve their work efficiency.
SilverLight can create an extremely artistic application with the following features:
◆ A cross-browser and cross-platform technology. It can run in all popular browsers, including Microsoft Interner Explorer, Mozilla Firefox, Apple Safari, and Opera. It can also run on Microsoft Windows and Apple Mac OS X.
◆ Consistent user experience can be provided wherever running.
◆ A small file needs to be downloaded for installation. It takes only a few seconds.
◆ Its video and audio streams provide video quality in 720 p HDTV video mode on both mobile devices and desktop browsers.
◆ Users can directly control the image in the browser, which can be dragged, flipped, or zoomed in.
◆ It reads data and updates the appearance, but does not interrupt user operations by refreshing the overall page.
SilverLight integrates multiple technologies into one development platform, where you can select the appropriate tools and programming languages that meet your needs. SilverLight provides the following features:
◆ WPF and XAML. SilverLight includes the Windows Presentation Foundation (WPF) technology, which greatly extends browser elements when creating user interfaces. WPF allows you to create a combination of graphics, animations, media, and other rich client features. It extends the browser-based user interface and surpasses the features provided by HTML. The Extensible Application Markup Language (XAML) provides declarative markup for creating WPF elements.
◆ JavaScript extension. SilverLight provides extensions to the global Browser Scripting Language to provide more powerful controls for browser user interfaces, including the ability to work with WPF elements.
◆ Cross-browser and cross-platform support. SilverLight is consistent across all popular browsers (any platform. Designing and developing applications does not need to worry about what platform or browser your users are.
◆ Integration with existing applications. SilverLight can be seamlessly integrated with existing JavaScript and ASP. net ajax code without missing functions.
◆ You can access the. NET Framework programming model and related tools. You can use managed dynamic languages such as Jscrit, IronPython, C #, and VB to create SilverLight-based applications. You can use development tools such as Visual Studio to create SilverLight-based applications.
◆ LINQ. SilverLight contains the Integrated Query (LINQ) language.
◆ If ASP. NET is already used, you can integrate SilverLight into the familiar ASP. NET server and client functions. You can create server-based resources in ASP. NET, and use the AJAX feature of ASP. NET to interact with server resources without interrupting users.
Development tools:
You can use existing skills and familiar tools to create Silverlight-based applications. on the Web page, you can use HTML or Silverlight WPF elements, just like HTML, in Web applications, XAML can also use declared tags to create user interfaces. The difference is that XAML provides more powerful elements.
You can use powerful Visual S... the remaining full text>

What are precautions for deploying ASPNET + Silverlight programs on server 2003 R2 (server )?

ASP. NET + Silverlight programs deployed on server 2003 R2 (server ???????

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.