Summary

TMetadata class is used internally to handle all required by serialization engine type descriptors. In current version it does not provide any useful access to cached data. There are only two public methods which can be used by the user: NG.Serialization.TMetadata.RegisterClass(TClass) and NG.Serialization.TMetadata.RegisterClasses(array of TClass).

Syntax

TMetadata = class

Constructors

 NameDescription
Create 
Top

Methods

 NameDescription
RegisterClass

RegisterClass procedure allows to register class type in serialization engine.

RegisterClasses

RegisterClasses procedure allows to register several classes at once in serialization engine.

Top

Remarks

TMetadata class is used internally to initialize and cache types related data used by serialization engine. Semantic check of used attributes are performed while data initialization. Thus, the user can get attribute usage errors. There are two different time frames in which user can get these errors:

  • At application startup time: since serializer/de-serializer interfaces use template methods, its possible to initialize used  type descriptors at application startup time. This technique is implemented mostly for performance reasons, because it allows to hook required descriptors without even looking in cache.
  • At run-time: some descriptors can be lazy-initialized at run-time. If a type is not used in template methods calls, nor it used as a property or field type, it will not be initialized at application startup. The most common example of such types is when the property of object type contains object value of one of its descendants. This way the descriptor for real object value class will be lazy initialized on the fly.
Thus, sometimes its required to use NG.Serialization.TMetadata.RegisterClass(TClass) or NG.Serialization.TMetadata.RegisterClasses(array of TClass) to initialize class type descriptors before de-serializing data. Otherwise, the situation is possible, when de-serializer will be unable to find de-serialized object type.

See Also

Reference