Template Lookup Mechanism.

Mydra Center can use custom visual representation of its different visual parts.
a visual part is an element which provides data to be represented on screen. It may or may not come with its own specific template.

a skin is a set of settings defining which template every single visual part will use.

In order toresolve the template a visual part should use, it must rely on its TemplateKind.
A TemplateKind defines what kind of template must be used to render the visual part. For instance, a visual part providing a number could ask the TemplateProvider for a TemplateKind with the value "number".

If this number is something more specific, like a rating, and should use a more complex representation than a regular number, the TemplateKind should be specialized, using a namespace-like approach : "number.rating"

This can be extended to filter even more and make distinction between different TemplateKinds : "number.rating.imdbrating" "number.rating.tvdotcomrating"
This provides the user of the application with a way to use fallback, so that if a Visual Part cannot find a proper template, an alternative template can be used. typically : if no template is registered with the templateKind "number.rating.imdbrating", the template registered with the templateKind "number.rating" can be used instead.

a visual part can also inject its own template in the lookup process by passing the template and its templateKind as a parameter.

When the TemplateProvider is used for the first time, it will import all the existing templates, and register all those which were defined in the skin with their templateKind

the lookup process will unfold as follows :

1. if an exact templatekind match is found in the registered templates, the template will be returned.
2. if the templateKind requested and the templateKind of the injected template are identical, then the injected template is returned.
3. take the "parent" of the templateKind as the new templateKind ( "www.xxx.yyy.zzz" --> "www.xxx.yyy" )
4. Go back to step 1

Actual Example :

BrowserItem.Disk.Media.Detail.video/avi : the template for the detail panel of an avi video when a media element is selected from the browser of a disk-based view (disk-based versus library-based i.e. the media is identified by its filename rather than by its title/artist/other metadata.)

--> if only BrowserItem.Disk.Media.Detail is defined : All media types will look the same
--> if only BrowserItem.Disk.Media is defined : All media types will look the same and The Detail panel will have the same template as the element in the "Master" view.
--> if only BrowserItem.Disk is defined : All browser item will look the same, but with a disk-based view specific emplate and The Detail panel will have the same template as the element in the "Master" view. (alternative : BrowserItem.Library )
--> if only BrowserItem is defined : All browser item will look the same, with a very basic and simple template, probably unusable, and The Detail panel will have the same template as the element in the "Master" view.

Last edited Jul 22, 2010 at 11:04 AM by salfab, version 6

Comments

salfab Apr 18, 2010 at 12:17 PM 
if no template is found and we have to resort to use the tostring representation of the visual part : should we have a look in the imported templates which were not registered in the skin and "guess" which template to use ?