Returns a strongly typed object deserialized from the JSON data in the node.config file included in the custom node .s9n file.
public T LoadConfig<T>();
Classes: CustomNode, CaptureImporter, ActionImporter
Type Parameters
T
Type of config object.
Returns
T
An object of type T deserialized from the JSON in node.config.
Example
The following example demonstrates loading a user defined type object from a config.json file of appropriate design.
First, let it be assumed that the config.json file within the custom node .s9n holds the following JSON data:
{ "Source":"C:\\Source", "Destination":"C:\\Destination" }
This JSON object holds property values for properties named "Source" and "Destination".
Your custom code can de-serialize this information into a C# object like so:
// MyConfig class is defined as such class MyConfig { public string Source { get; set; } public string Destination { get; set; } } public override void Run() { // Loading the config object from config.json var myConfig = LoadConfig<MyConfig>(); // Read the values LogMessage(myConfig.Source) // C:\Source LogMessage(myConfig.Destination) // C:\Destination }
Remarks
The type passed to the LoadConfig method can be as primitive or as complex as needed, provided the JSON data inside config.json can successfully deserialize to the destination type.