Prism frame interpretation of a series of

Source: Internet
Author: User
Tags silverlight

noun explanation

1. What is the IOC

IOC is the abbreviation for inversion of control, and most books are translated into "inversion of controls".

IOC and Dependency Injection (DI) are so-called dependency injections, that is, when the IOC container is running, it dynamically injects some kind of dependency into the object.

2. Bootstrapper:

Using a framework in a program requires finding a pointcut, inserting the framework into it, and delegating a subset of the functionality to the framework. The pointcut that uses prism in Silverlight is the Application_Startup method in App.xaml.cs. In general, this method only specifies the page that the page loads first, but we remove the default logic and replace it with bootstrapper. When the Bootstrapper.run method is called, it will do some preparatory work, such as some configuration. So you'll find that when you use PRISM, it's slower to start the program than normal, because Bootstrapper does a lot of work. By default, Prism provides two bootstrapper--unitybootstrapper and mefbootstrapper based on specific containers, using unity and MEF to implement dependency injection, respectively. Bootstrapper Detailed Introduction See

3. Module:

Prism helps us break down the program into functional modules called module, usually a project is a module. Since the module is separate from each other, it needs to be integrated at run time, so Prism needs to know the existence of the module, which involves modulecatalog. A module is a collection of logically related assemblies or resource files that are typically present in a XAP file in a Silverlight program. Each module requires a role that is responsible for initializing and integrating with the system, and it needs to implement the IModule interface. There is only one initialize method in the IModule interface, on the one hand this interface marks the project as a module, on the other hand you can implement some logic in the Initialize method, such as registering some service to the container, or integrating the view into the program, and so on.

Module details see

1) Moduleinfo

Moduleinfo is the abstraction of module, including the name, type, dependency and other information of module. After creating a module, you need to notify the existence of the module, which is to register it. In Prism, the module exists in the form of Moduleinfo. Moduleinfo records the module's information, the ModuleName attribute is the identifier of the module, and the equivalent of module Id;moduletype is the module's AssemblyQualifiedName The DependsOn property is a collection of the modulename of the other module that the module relies on, and when the module is loaded, dependencies are loaded first if there are no dependencies loaded; Initializationmode, there are two cases-- Whenavailable and OnDemand, when Whenavailable is selected, the module will load automatically when the program starts, and if OnDemand is selected, it will be loaded on demand and whenavailable;ref by default. The location where the module is stored, such as Xxx.xap;state, defines the state of the module from its registration to the entire process of loading to initialization.

2) Modulecatalog

Modulecatalog is the module's container, which contains all the module information, in the form of moduleinfo exist. Modulecatalog:modulecatalog implements the Imodulecatalog interface, which is a moduleinfo container that holds information about all the module in the system and not only manages which module needs to be loaded, When to load issues such as what order to load, but also to check whether there are cyclic dependencies between the module, whether there are duplicate module, and so on. Modulecatalog provides a constructor method and a Addmodule method that can be used to register the module in code, and you can also configure the module in a XAML file. It is then loaded by the Modulecatalog.createfromxaml method.

3) Modulemanager

The Modulemanager implements the Imodulemanager interface. As the name implies, the class that manages module. The Imodulemanager contains two methods and two events: the Run method loads all the module Initializationmode as whenavailable and initializes it. The initialization work is delegated to Imoduleinitializer, which obtains an instance of the module class (the class that implements the IModule interface) and then calls its Initialize method. The LoadModule method is used to load the module Initializationmode as OnDemand. Two events are used to inform the download module of the progress of the changes and module loading is complete.

4. Region:

Equivalent to ContentPlaceHolder in ASP. (Is that what you call it?) ), which acts as a placeholder, as in this case there are two Region--regiona and regionb in the shell, defining two areas. During the initialization of module, the pages in module are put into the defined region by Iregionmanager . Iregionmanager is responsible for managing region, where it can register view, navigate, and so on.

The developer will be responsible for creating shell programs, hosting applications, and qualifying regions (region). Region is a placeholder (placeholder) that can load dynamic content from modules (module). The module should be built in a standard MVC pattern with one or more views, a controller, and a model.

The PRISM framework provides the module catalog, the module manager, and the region manager. We can generate a directory of modules through code, XAML files, configuration files, or traversing directories. The manager then loads the module in an instant or on-demand basis. The last zone manager loads the view from the module into the correct zone.

5. Container:

Dependency Injection container. The benefits of using dependency injection in your program can be found everywhere. One obvious benefit of using containers in Silverlight to manage individual components is to use a singleton to reduce memory usage. Otherwise, each time a page is loaded, it will need to be re-created and resource-intensive. Of course the benefits are not just these, but it is quite convenient to inject some services through the container (Iregionmanager and Itextprovider in this example).

Dependency injection containers are used to resolve dependencies between components, and resolving dependencies usually makes the container aware of the types and instances in which it is used to resolve dependencies (registration), and obtains these references in a consumer class (resolution). The Prism class library supports the managed extensibility Framework and (MEF), Unity Application Block (Unity) container, but it is not a unique container. Because the class library accesses the container through the Iservicelocator interface. The container can be replaced. To use a different container, simply implement the Iservicelocator interface and expose your container API to register and resolution. And, if you want to replace the container, you have to implement your own specific bootstrapper. The Iservicelocator interface is defined in the Common Service Locator class library. This is an open source achievement that implements an IoC (inversion of Control) abstract container, such as a dependency injection container, and a service locator. The purpose of using this class library is to collaborate with IOC and service Locator.

The Prism Class library provides mefservicelocatoradapter and Unityservicelocatoradapter. The Mefbootstrapper class and the Unitybootstrapper class register their respective iservicelocator implementations and use the required containers when dependency injection is required, as long as the Prism Class library code is used, You can ensure that the Prism class library and the container used are decoupled.

For self-developed code, you can simply base your code development on the API of the container you choose. You don't have to go through Iservicelocator abstraction unless you want your code to be agnostic to the container. For example, the Prism Reference Guide and the reference implementation demonstrate APIs that are not directly implemented based on MEF and unity containers.

6. Shell:

This is equivalent to the entry of the program, the initial interface, and the ability to provide a master page similar to ASP. The shell must be created by bootstrapper, because some of the service that the shell needs to use, such as Regionmanager, needs to be registered before the shell is displayed.

7. View and view model views and ViewModels

Views are part of the UI that contains the appearance form. You can think of it as a user control that renders on the client. In fact, the Prism class library does not have to be defined as a user control. You can use data templates to define a view to render model data. View can be freely rendered through WPF's ability to render the interface. Simply put, view is a collection of UI elements that define the UI rendering section, which provides a form of encapsulation of individual parts of your UI.

The Model-view-viewmodel (MVVM) pattern has become the most commonly used mode in Wpf/silverlight display mode. When you use the MVVM pattern, the views view is associated with the view model in the runtime and provides data and interactive logic to support the presentation of view views.

Eventaggregator. Composite application often need to communicate with other components and services in the application in a Loosely coupled. To support this, Prism provides the eventaggregator component, which implements a Pub-sub event mechanism, Thereb Y allowing components to publish events and other components to subscribe to those events without either of them requiring A reference to the other. The eventaggregator is often used to allow components defined in different modules to communicate .

8. Eventaggregator

In an integrated system, components often need to be loosely coupled with other components and services. Prism provides Eventaggregator, which implements a Pub-sub event mechanism that allows components publish events and other components to subscribe to events. Eventaggregator are often used to allow communication between different modules of a component.

9. Navigation.

Navigation is defined as the process by which the application coordinates changes to its UI as a result of the user's inte Raction with the application or internal application state changes. Prism supports-styles of navigation:

State-based navigation, where the state of a existing view is updated to implement simple navigation scenarios,

and view-switching navigation, where new views is created and old views replaced within the application ' s UI. View-switching Navigation uses a Uniform Resource Identifier (URI) –based navigation mechanism in conjunction with Prism re Gions to allow flexible navigation schemes to be implemented.

Navigation defines the process of applying coordinates to adjust UI due to user interaction affecting application or domestic application state changes. Prism supports two styles of navigation: state-based navigation, the country updates existing ideas to implement simple navigation system schemes, and the other is view-switching navigation, in the creation and new views to replace the old have views in the application's UI. View-switching navigation uses a Uniform Resource Identifier (URI)-base navigation mechanism and PRISM regions to form a flexible navigation solution.

Ten. multi-targeting

When using separate presentation modes, such as MVVM or MVP mode, you can detach the display from your application's user interface and business logic. View model, presenter and model, can be reused in WPF and Silverlight. Wpf-specific and Silverlight-specific views can-then is defined in a-to-encapsulates the UI for each.

Prism frame interpretation of a series of

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.