using System.Data.SqlClient; var connString = "Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=True"; var conn = new SqlConnection(connString); var engine = new ScriptEngine(); engine.AddHostObject("database", conn);
public class Person { public string Name { get; set; } public int Age { get; set; } } var person = new Person { Name = "John", Age = 30 }; var engine = new ScriptEngine(); engine.AddHostObject("john", person);In this case, the package library used would be the application's own assemblies. Overall, the AddHostObject method is a powerful tool for integrating scripts with a .NET application, allowing for dynamic and flexible interactions between the two. The package libraries used will depend on the specific objects and functionality being exposed to the script environment.