PropertyInfo Setvalue

G

Guest

I'll big problem.

I have tree class:
public Class Column
{
public Column
{...}
string _Value;
public bool HasValue = false;

public string Value
{
set
{
_Value = value;
HasValue = true;
}
}
...
}

public Class Customer
{
public Customer
{...}
public Column Name;
public Column EMail;
....
}

public Class CustomerBL
{
public CustomerBL
{...}
public Cliente Parameters;
....
}

Normally I use thus:
CustomerBl oCustomer = new CustomerBL();
oCustomer.Parameters.Name.Value = "Steve Bug";
oCustomer.Parameters.EMail.Value = "(e-mail address removed)";
This form OK.

Now it is that they are they, as to set the Value property using Reflection?

object Customer;
//Load DLL
Assembly tempAssembly = Assembly.LoadFrom(DLL Path);
//Create Object Customer
Customer = tempAssembly.CreateInstance(Customer);

Type Tp = Customer.GetType();

Tp.GetField("Parameters").FieldType.GetField("Name").FieldType.GetProperty("Value").SetValue(Which object put here? , "Mike Ronald", null);

Are you know as to make this?
Tanks.
 
B

Bart Mermuys

Hi,

Hugo Leonardo said:
I'll big problem.

I have tree class:
public Class Column
{
public Column
{...}
string _Value;
public bool HasValue = false;

public string Value
{
set
{
_Value = value;
HasValue = true;
}
}
...
}

public Class Customer
{
public Customer
{...}
public Column Name;
public Column EMail;
....
}

public Class CustomerBL
{
public CustomerBL
{...}
public Cliente Parameters;

Didn't you mean "public Customer Parameters;" otherwise i'm confused.
....
}

Normally I use thus:
CustomerBl oCustomer = new CustomerBL();
oCustomer.Parameters.Name.Value = "Steve Bug";
oCustomer.Parameters.EMail.Value = "(e-mail address removed)";
This form OK.

Now it is that they are they, as to set the Value property using
Reflection?

object Customer;
//Load DLL
Assembly tempAssembly = Assembly.LoadFrom(DLL Path);
//Create Object Customer
Customer = tempAssembly.CreateInstance(Customer);

Type Tp = Customer.GetType();

Tp.GetField("Parameters").FieldType.GetField("Name").FieldType.GetProperty("Value").SetValue(Which
object put here? , "Mike Ronald", null);

Assembly tempAssembly = Assembly.LoadFrom(DLL Path);
object oCustomerBL = tempAssembly.CreateInstance("Namespace.CustomerBL");
object oCustomer =
oCustomerBL.GetType().GetField("Parameters").GetValue(oCustomerBL);
object oColumn = oCustomer.GetType().GetField("Name").GetValue(oCustomer);
oColumn.GetType().GetProperty("Value").SetValue(oColumn, "Mike Ronald",
null);

HTH,
Greetings
 
G

Guest

That is great......... :)
Tank you very much..

Bart Mermuys said:
Hi,



Didn't you mean "public Customer Parameters;" otherwise i'm confused.


Assembly tempAssembly = Assembly.LoadFrom(DLL Path);
object oCustomerBL = tempAssembly.CreateInstance("Namespace.CustomerBL");
object oCustomer =
oCustomerBL.GetType().GetField("Parameters").GetValue(oCustomerBL);
object oColumn = oCustomer.GetType().GetField("Name").GetValue(oCustomer);
oColumn.GetType().GetProperty("Value").SetValue(oColumn, "Mike Ronald",
null);

HTH,
Greetings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top