KspData LoadKspFile T  Method (String, String) KerbalData - KSP Data Unlocked!
Loads and de-serializes a KSP data file into the requested type

Namespace: KerbalData
Assembly: KerbalData (in KerbalData.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

public static T LoadKspFile<T>(
	string path,
	string configSectionName = null
)
where T : class, new()

Parameters

path
Type: OnlineSystem String
full path of file location
configSectionName (Optional)
Type: OnlineSystem String
configuration section name to use for processor lookup
Type Parameters

T
model type to de-serialize to

Return Value

de-serialized object instance
Examples

A null configuration causes the class to load embedded defaults. This is good for most common uses and is the recommended way for loading individual files. A type parameter must be supplied to the method so the correct type can be serialized. KerbalData is not yet able to determine the type from the data loaded. The developer must provide this information.

var data = KspData.LoadKspFile<SaveFile>(@"C:\my\file\location\filename.ext");

If a configuration section name is provided, KspData will load the named .NET configuration and use it's data in creating the ProcessorRegistry used in serialization. The following example is the same configuration that is used by default.

var data = KspData.LoadKspFile<SaveFile>@"C:\my\file\location\filename.ext", "kerbalData");
See Also