public Sitplugin Load(string json) { Sitplugin sitplugin = null; JObject obj = JObject.Parse(json); string outputPath = System.IO.Path.GetFullPath((string)obj["output_path"]); string archive_index_db_path = null; if (obj["archive_index_db_path"] != null) { archive_index_db_path = System.IO.Path.GetFullPath((string)obj["archive_index_db_path"]); } var mappingConfig = obj["mapping_config"]; if (mappingConfig == null) { throw new Exception("missing mapping_config section"); } bool initialize_mapping = mappingConfig["initialize_mapping"] == null ? false : (bool)mappingConfig["initialize_mapping"]; CBMSIT.UserData.UserDataSet userData = null; if (obj["import_config"] != null) { var importConfig = obj["import_config"]; if (importConfig["path"] != null) { userData = Sitplugin.ParseSITData( path: System.IO.Path.GetFullPath((string)importConfig["path"]), AgeClassTableName: (string)importConfig["ageclass_table_name"], ClassifiersTableName: (string)importConfig["classifiers_table_name"], DisturbanceEventsTableName: (string)importConfig["disturbance_events_table_name"], DisturbanceTypesTableName: (string)importConfig["disturbance_types_table_name"], InventoryTableName: (string)importConfig["inventory_table_name"], TransitionRulesTableName: (string)importConfig["transition_rules_table_name"], YieldTableName: (string)importConfig["yield_table_name"]); } else if (importConfig["ageclass_path"] != null) { userData = Sitplugin.ParseSITDataText( ageClassPath: System.IO.Path.GetFullPath((string)importConfig["ageclass_path"]), classifiersPath: System.IO.Path.GetFullPath((string)importConfig["classifiers_path"]), disturbanceEventsPath: System.IO.Path.GetFullPath((string)importConfig["disturbance_events_path"]), disturbanceTypesPath: System.IO.Path.GetFullPath((string)importConfig["disturbance_types_path"]), inventoryPath: System.IO.Path.GetFullPath((string)importConfig["inventory_path"]), transitionRulesPath: System.IO.Path.GetFullPath((string)importConfig["transition_rules_path"]), yieldPath: System.IO.Path.GetFullPath((string)importConfig["yield_path"])); } else { throw new Exception("error in import_config section"); } sitplugin = new Sitplugin(outputPath, initialize_mapping, userData, archive_index_database_path: archive_index_db_path); MapSpatialUnits(sitplugin, mappingConfig["spatial_units"]); MapSpecies(sitplugin, mappingConfig["species"]); MapNonForest(sitplugin, mappingConfig["nonforest"]); MapDisturbanceTypes(sitplugin, mappingConfig["disturbance_types"]); } else if (obj["data"] != null) { sitplugin = new Sitplugin(outputPath, initialize_mapping, archive_index_database_path: archive_index_db_path); sitplugin.AddAgeClasses( (int)obj["data"]["age_class"]["age_class_size"], (int)obj["data"]["age_class"]["num_age_classes"]); foreach (var c in obj["data"]["classifiers"]) { sitplugin.AddClassifier((string)c); } MapSpatialUnits(sitplugin, mappingConfig["spatial_units"]); MapSpecies(sitplugin, mappingConfig["species"]); MapNonForest(sitplugin, mappingConfig["nonforest"]); MapDisturbanceTypes(sitplugin, mappingConfig["disturbance_types"]); LoadConfigDataObjects(sitplugin, obj["data"]); } else { throw new Exception("expected one of 'import_config', or 'data' in configuration"); } return(sitplugin); }