Sunday, February 26, 2012

DTSProperty.GetValue

Hi,
Seems a pretty straightforward problem however, I have now spent some time on it. I have a DTSProperty object and want to get its value. I am able to get all the other attributes like Name, Type just fine. The GetValue method on the DTSProperty class takes a object and returns a object. If I want to get a value of the current property what do I pass to GetValue?
I have something like

foreach (DtsProperty property in controlFlow.Properties)
{
string propName = property.Name;
//I want to do this
if(property.Get)
property.GetValue(?)//what do I pass in here

}

Thanks,
-Suri.

object x = property.GetValue(controlFlow);|||Thanks Darren. It works just fine. However I am not sure why the GetValue method was designed to take a TaskHost object as opposed to the IDTSCustomProperty90 which has a value property on it.|||Yes I know what you mean. I read the BOL section and thought that, but looking at code I have that works, well that is what worked.|||This is an optimization. Each object type (more accurately, interface) is chached internally for property objects. Were it not so, property objects would multiply geometrically. When you get a pointer to the properties collection, you're actually getting a pointer to a template collection for the interface. When you get the value, then the template asks the object you pass in for the value.
Make sense?
K

No comments:

Post a Comment