473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

PropertyInfo Setvalue

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 = "bu*@test.com";
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(Whi ch object put here? , "Mike Ronald", null);

Are you know as to make this?
Tanks.
Nov 22 '05 #1
2 2470
Hi,

"Hugo Leonardo" <Hu**********@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
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 = "bu*@test.com";
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(Whi ch
object put here? , "Mike Ronald", null);
Assembly tempAssembly = Assembly.LoadFrom(DLL Path);
object oCustomerBL = tempAssembly.CreateInstance("Namespace.CustomerBL" );
object oCustomer =
oCustomerBL.GetType().GetField("Parameters").GetVa lue(oCustomerBL);
object oColumn = oCustomer.GetType().GetField("Name").GetValue(oCus tomer);
oColumn.GetType().GetProperty("Value").SetValue(oC olumn, "Mike Ronald",
null);

HTH,
Greetings

Are you know as to make this?
Tanks.

Nov 22 '05 #2
That is great......... :-)
Tank you very much..

"Bart Mermuys" wrote:
Hi,

"Hugo Leonardo" <Hu**********@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
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 = "bu*@test.com";
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(Whi ch
object put here? , "Mike Ronald", null);


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

HTH,
Greetings

Are you know as to make this?
Tanks.


Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony Tullemans | last post by:
I am trying to write a subroutine that will examine all the properties of a form to determine which of those are SqlCommand objects, and then set the Connection property of those SqlCommands to a...
2
by: Hugo Leonardo | last post by:
I'll big problem. I have tree class: public Class Column { public Column {...} string _Value; public bool HasValue = false;
0
by: Bob | last post by:
This works only when the property return type is string: SomeObjectsPropertyInfo.SetValue(SomeObject, SomeStringValue, Nothing) Is there a good way to try to automatically cast the string value...
15
by: Charles Law | last post by:
I have adapted the following code from the MSDN help for PropertyInfo SetValue. In the original code, the structure MyStructure is defined as a class MyProperty, and it works as expected. There is...
1
by: Paul | last post by:
This part is easy: Dim oControl As Control oControl = Me.Page.FindControl("TextBox1") Dim oPropertyInfo As PropertyInfo oPropertyInfo = oControl.GetType.GetProperty("Text") ...
3
by: ThisBytes5 | last post by:
I am trying to save/retreive some settings from a database using reflection an my custom attributes. The field in teh database is a string, but my property is a boolen. I have the following code: ...
0
by: tatilou | last post by:
Hello, I need add new method to my properties. these methods should give me some attributes coming from my database. I think, to create a class with implement PropertyInfo but I don't know...
2
by: Carlos Rodriguez | last post by:
I have the following function in C#public void Undo(IDesignerHost host) { if (!this.componentName.Equals(string.Empty) && (this.member != null)) { IContainer container1 = (IContainer)...
9
by: FourEyes | last post by:
I've read that Reflection is slow and shouldn't be used when performance is a concern. In my case, performance is definitely a concern, so I was thinking that I could collect the PropertyInfo...
1
by: damiensawyer | last post by:
Hi, I need to invoke .getvalue and .setvalue on fieldinfo and propetyinfo objects. Even though they're both derived from MemberInfo, they don't share those two methods. I've finding myself...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.