Yes, you're right FieldType is what you need...
There are no values in the runtime object, because you didn't set them. This
can be done via constructor ( you specify parameters for the constructor,
also this assumes that you have appropriate constructor with the same
parameter list).
calling with Object[] parameter = {}; is equivalent to
SQB.SQBDataprovider obj = new SQB.SQBDataprovider();
and Object[] par = new object[2] {"connstr", "other"};
is equivalent to
SQB.SQBDataprovider obj = new SQB.SQBDataprovider("connstr", "other");
Another way is to set them manually
sqbdp = o as SQB.SQBDataprovider;
sqbdp.ConnectionString = "somestring";
etc.
Also after sqbdp = o as SQB.SQBDataprovider;
you do not check for null, may result in NullRef Exception.
--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com
"layos" <gl****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi Vadym, thank you very much, I'm near the solution, but i have two
questions.
First, fieldinfo[n].ReflectedType match the Type of the Component Class
and not of the Object inside. I try to use fieldinfo[n].FieldType and
it appears to be correct. Is it right?
The second question is: my objects inside the component class have some
properties like "connection string", "query", "parameters" but the
object created at runtime does not appear to mantain them.
Where is my mistake?
FieldInfo[] f;
Type SqbqueriesType = typeof(sqbfilters);
f = SqbqueriesType.GetFields(BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.Public);
DataSet ds = new DataSet();
SQB.SQBDataprovider sqbdp;
for(int i = 0; i < f.Length; i++)
{
if(f[i].Name == "mysqbprovidertest")
{
Type[] constructorArgs = { typeof(SQB.SQBDataprovider) };
Type t = f[i].FieldType;
ConstructorInfo c =
t.GetConstructor(System.Type.EmptyTypes);
Object[] parameter = {};
Object o = c.Invoke(parameter);
sqbdp = o as SQB.SQBDataprovider;
sqbdp.Fill(ds);
}
}
"sqbfilter" is the name of Component Class where i instanciate the
SQB.SQBDataprovider objects.
Thank you very much, I owe your beer ;)
--
Layos