473,387 Members | 3,820 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,387 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 2471
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.