You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the syntax node to model class marshaling is hidden behind the internal class SyntaxToModelTransform. Sometimes it is useful to do "delayed" marshaling where first a TomlTable value is captured and then later marshaled into its model class.
Consider a scenario where a modular application loads its configuration from a single file. A hypothetical T Toml.ToModel<T>(TomlObject) method would be very useful here.
classConfigProvider{privatereadonlyTomlTable_toml;publicT?LoadConfig<T>(stringsection){if(_toml[section]is not TomlObject obj)returndefault;return Toml.ToModel<T>(obj);}}
This system is already implemented in the SyntaxToModelTransform class, it is just not exposed to the outside world. Right now the only way to achieve this behavior is to first transform the table back into TOML and then transform that string into the model class. This is not only wasteful, but also destroys TOML trivia.
The text was updated successfully, but these errors were encountered:
cryocz
changed the title
Expose syntax to model visitor
Expose "syntax to model" visitor
Nov 11, 2022
Right now the syntax node to model class marshaling is hidden behind the internal class
SyntaxToModelTransform
. Sometimes it is useful to do "delayed" marshaling where first aTomlTable
value is captured and then later marshaled into its model class.Consider a scenario where a modular application loads its configuration from a single file. A hypothetical
T Toml.ToModel<T>(TomlObject)
method would be very useful here.This system is already implemented in the
SyntaxToModelTransform
class, it is just not exposed to the outside world. Right now the only way to achieve this behavior is to first transform the table back into TOML and then transform that string into the model class. This is not only wasteful, but also destroys TOML trivia.The text was updated successfully, but these errors were encountered: