C# Dynamic List Class -
i have bit of weird issue. working in c# script ssis have developed need build list based off dynamic data.
background
to explain it, script task fired has variable api url, goes off , pulls json string , throws typed list using following code.
var listobject = get_apidata<applicationonedataset>(url)
the class long winded , not needed in context of issue. applicationonedataset typed match 1 of possible json results returned get_apidata
.
now have need change applicationonedataset applicationtwodataset dynamically based on api url pass script.
so have done send through second variable script called class name contains string "applicationdatasetone" or "applicationdatasettwo" based on context call under.
the question
my question how can dynamically vary line:
var listobject = get_apidata<applicationonedataset>(url)
with string variable passed script.
my original thinking along lines of this:
var classtype = (string) dts.variables["appclassname"].value; type type = type.gettype(classtype); var listobject = get_apidata<type>(url)
though doesn't seem that. tips great!
as long there 2 types can use , know them @ compile time, not further simple if
. works, it's easy, understands it.
you can totally dynamic @ runtime, that's huge pain in the... don't want be. if want go down rabbit hole, can find more information here.
Comments
Post a Comment