eXtensions Framework. How XF Works

This topic describes the principles of construction and work of the eXtensions Framework.

Table of content:

  • XFAssembly.dll generation
  • Persistent and non persistent Entities and Extensions

XFAssembly.dll generation

Data model design based on the XF principles widely use the Entities and Extensions notions. In general, Entity Extension implemented in a separate module (XCRM), which depends on the Entity module (Core). Figure below demonstrate this.

extensions_framework_7

Therefore, the relation from the Entity to the Extension can only appear in runtime (marked by dashed line). This relation should be persistent and effectively used in queries to the data.

eXtensions Framework solves this problem by creating a special assembly (XFAssembly).

extensions_framework_8

The approach to create XFAssembly is similar to methodology for Domain Components

  1. Register Entities and its Extensions in application
  2. Generate cs-cjde with all required classes and interfaces
  3. Compile generated code to dynamic assembly
  4. If the compilation is successful, load the obtained assembly in the domain
  5. Register new DC in application

Note

For every Entitie with NNN name the framework will generate an descendant with _NNN name in XFAssembly. This DC contains all the emerging relationships between Entities and Extensions. The NNN Entity, in turn, will be extended with the calculated Exts property of the _NNN type, it serves to access properties of the generated _NNN type.

Note

XFAssembly is always stored on the hard disk. This is necessary in order to compile DCAssembly. XFAssembly location depends on how was set DCAssembly storage method.

Starting method

The path to the folder for storage XFAssembly

Win

<UserProfile>\AppData\Local\Temp\Xafari\<ApplicationName>\<random> or current folder

Web

<Temporary ASP.NET Files>

ModelEditor

<UserProfile>\AppData\Local\Temp\Xafari\<ApplicationName>\<random>

Persistent and non persistent Entities and Extensions

When designing the data model may be a situation when a problem requires the use non persistent Entities and Extensions. It is possible a few situations each of them requires a different number of database tables.


Persistent Entity

Non  persistent Entity

Persistent Extension

2

1

Non persistent Extension

1

0

Persistent Entity and persistent Extension

Contact persistent Entity extends with the XContact_CustomerInfo persistent Extension.

extensions_framework_9

_Contact and _XContact_CustomerInfo are persistent DC that are mapped to the Contact and XContact_CustomerInfo accordingly, it is inherited mapping. There are two tables in database, it is a Contact and XContact_CustomerInfo.

In this case, for the Contact Entity and XContact_CustomerInfo Extension two DC will be generated as shown in the figure above, there is bilateral association between them and _XContact aggregates _XContact_CustomerInfo.

Persistent Entity and non persistent Extension

Contact persistent Entity extends with the XContact_Address non persistent Extension.

extensions_framework_10

_Contact is persistent DC, which is mapped to the Contact, it is inherited mapping. _Contact contains non persistent _XContact_Address DC. There is one table in database, it is a Contact.

In this case, for the Contact Entity and XContact_Address Extension two DC will be generated as shown in the figure above, there is inheritance between them.

Non persistent Entity and persistent Extension

Contact non persistent Entity extends with the XPerson_PersonalData persistent Extension.

extensions_framework_11

_XPerson_PersonalData is a persistent DC which is mapped to the XPerson_PersonalData, it is inherited mapping. There is one table in database, it is a XPerson_PersonalData.

In this case, for the Person Entity and XPerson_PersonalData Extension two DC will be generated as shown in the figure above, there is bilateral association between them and _Person aggregates _XPerson_PersonalData. _XPerson_PersonalData.Person property is calculated, its persistence is implemented using _XPerson_PersonalData.Person_ hidden property of the GuidWeakReference type.

Non persistent Entity and non persistent Extension

Person non persistent Entity extends with the XPerson_Titles non persistent Extension.

extensions_framework_12

_Person and _XPerson_Titles are non persistent DC and not have their own tables. The using of this variant is considered in Entities inheritance section below.

In this case, for the Person Entity and XPerson_Titles Extension two DC will be generated as shown in the figure above, there is inheritance between them.

Entities inheritance

It is possible to inherit one Entity from another. If base Entity is non persistent, then its Extensions are also Extensions of descendants.

extensions_framework_13

XPerson_Titles Extension of the Person Entity is also Extension of the Contact Entity.