Class CustomViewRegistry

Definition

Namespace:
Tizen.NUI
Assembly:
Tizen.NUI.dll
API Level:
3

View the Registry singleton. Used for registering controls and any scriptable properties they have (see ScriptableProperty).

Internal Design from C# to C++

  • Each custom C# view should have it's static constructor called before any JSON file is loaded. Static constructors for a class will only run once ( they are run per control type, not per instance). Example of running a static constructor: System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (typeof(Spin).TypeHandle); Inside the static constructor the control should register it's type with the ViewRegistry For example:

static Spin() { ViewRegistry.Instance.Register(CreateInstance, typeof(Spin) ); }

The control should also provide a CreateInstance function, which gets passed to the ViewRegistry. // Eventually it will be called if DALi Builderfinds a Spin control in a JSON file. static CustomView CreateInstance() { return new Spin(); }

The DALi C++ equivalent of this is

TypeRegistration mType( typeid(Toolkit::Spin), typeid(Toolkit::Control), CreateInstance );

C#
Copy
public sealed class CustomViewRegistry
Inheritance
System.Object
CustomViewRegistry

Properties

View Source

Instance

Declaration
C#
Copy
public static CustomViewRegistry Instance { get; }
Property Value
Type Description
CustomViewRegistry
API Level: 3

Methods

View Source

Register(Func<CustomView>, Type)

The function which registers a view and all it's scriptable properties with DALi's type registry. Means the view can be created or configured from a JSON script.

The function uses introspection to scan a views C# properties, then selects the ones with [ScriptableProperty] attribute to be registered. Example of a Spin view registering itself: static Spin() { ViewRegistry registers control type with DALi type registry also uses introspection to find any properties that need to be registered with type registry ViewRegistry.Instance.Register(CreateInstance, typeof(Spin) ); }

Declaration
C#
Copy
public void Register(Func<CustomView> createFunction, Type viewType)
Parameters
Type Name Description
System.Func<CustomView> createFunction
Tizen.System.Type viewType
Exceptions
Type Condition
System.ArgumentNullException

Thrown when viewType is null.

API Level: 3