Universal Windows Program XMAL Services (Type System) Internal - Part 2

Before reading this article, I highly recommend reading previous part:

Application Launched

OnLaunched function is invoked when the application is launched. In this function, rootFrame.Navigate function is called with default MainPage arguments. Here XMAL Services come to play major role or other way around like, how navigate function is working.

Navigate function

Once this function is called what will happen. The following is an overview of the function called,

  1. Navigate method internally call the GetXamlType (IXamlMetadataProvider interface) method. It will pass the same Type object.
  2. GetXamlType check with XmalTypeInfoProvider class.
  3. XmalTypeInfoProvider load the request object type which is request by Navigate method.

Flow of the function call,

function

Code view

Navigate

Code view

XmalTypeInfoProvider class

XamlTypeInfoProvider object and store all the information like Page, datatype information.

Above image Application class GetXamlType function requested to the XamlTypeInfoProvider class load the type (page) via GetXamlTypeByType function.

Overview of the flow, GetXamlTypeByType function,

XmalTypeInfoProvider class

Code

see Code


This function first checks the cache dictionary, requested type already exits or not. If it is available return the IxamlType.

If it is not available requested to the LookupTypeIndexByType function get the Index of the type,

Index

LookupTypeIndexByType

Initially _typeTable is empty (Loading application object) and it calls the InitTypeTables() function to fill the _typeTable array and type check with this array return the Index. Now we get the Index & this value pass to the CreateXamlType function to create the object (IXamlType).

CreateXamlType function

Based on the index value read the typeName and type in the dictionary ( remember : blue print) , and this index value based object will create.

CreateXamlType function

typeName: User created page name in the toplevel ( ex : "App6.MainPage").

type: System type of the typeName (ex: typeof (global:App6.MainPage) ;).

Default ( check initial Navigate function we pass the MainPage) page object will create via XamlUserType class, check the arguments typeName and type pass as the “App6.MainPage” ( this page which I have created in the Visual Studio upper level ).

Here clear Page class are handleD in IXamlType .

Overview of the XMALUserType,

XMALUserType

Creating Base class (Page) Object

Create object check the XamlUserType constructor last parameter, GetXamlTypeByName("Windows.UI.Xaml.Controls.Page")); Creating XamlUserType first create the BaseType . The GetXamlTypeByName function has taken care for this job.

GetXamlTypeByName function execute like GetXamlTypeByType function until it reaches CreateXamlType function.

Create object

Note: typeIndex arguments as 1 : creating the Base object check the typeTable dictionary (remember : blue print) "Windows.UI. Xaml.Controls. Page" index is 1.

Internally Page class base object, XAML services created as XamlSystemBaseType object.
CreateXamlType function create the XamlSystemBaseType object (same IXmalType type)/

base object

Arguments

typeName: "Windows.UI.Xaml.Controls.Page".

type: typeof(global::Windows.UI.Xaml.Controls.Page);

Once base class object has created & return and XamlUserType class object has created. It created only the XamlUserType. The MainPage object is not yet assigned which is passed by the Navigate function, till now what will happen, based on the page which is added in the project, the same equivalent object created in the XMAL services (Not all the object because Navigate fuction only requested to the MainPage).

Assign the MainPage object:

MainPage

Assign the Datatype

Page object assigned & add the datatype which is handled in the MainPage, in the Member dictionary.

Example: Two string datatype (I have added SetHostName, SetIpName string in MainPage) those datatypes added in the,

string datatype

RunInitializer

All initialization has done, finally the RunClassConstructor (Run method) is called to create object (page) & activate the page.

Note: If you call this function many times (try separate sample) it calls constructor only one.

constructor

Object has successfully created, finally ActivateInstance method is called to create MainPage object and application object load this page in GUI.

load this page

Code

Finally, application is launched.

Output

Up Next
    Ebook Download
    View all
    Learn
    View all