Choosing a property of type businesslayer based on the name as a string


Author
Message
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
This is one of those things I do instinctively in Fox with Eval() or & and don't quite have the hang of yet in .NET



I have a number of private properties of type businesslayer



_Endorsements

_Premises

_GL

_Propmaster





I get a name ( but getting the displayvalue of an enum BOName ) of a business object.



The properties are named _



Now I want to look at the count of the BO based on the string which have representing



Dim varname as String = "_" & MicroFour.StrataFrame.Tools.Common.GetEnumDisplayValue(bo.BOName)



Lets say varname = "PROPMASTER"



Now I want to get the count of whatever BO is in the property which is in the string varname



i.e. Propmaster.count





Fumbling with syntax here. Appreciate any guidance.



TIA

Replies
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Charles,



For this kind of VFP EVAL() you have to use System.Reflection, even though I don't quite understand your logic.



I know you want to be able to access a BO instance just know its name or something like that. I think that if you post a quick sample on what you want to accomplish it would be easier.



I know the System.Reflection is the way to get these things done as in VFP EVALUATE() function, but I read many post of developers suggesting to be very careful about using reflection, don't know all the details, but perhaps after knowing more about your logic it could be done without it.

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Also if all you want is to get the bo instance based on its name, then you could try code like this:





Dim varname As String = "_Propmaster"

For Each boInForm As MicroFour.StrataFrame.Business.BusinessLayer In Me.BusinessObjects

If boInForm.GetType().Name = varname Then

MessageBox.Show(String.Format("BO Count = {0}", boInForm.Count), "Test")

Exit For

End If

Next





Play with it in the debugger and I am sure you will get what you want. Hehe

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search