I am just now seeing that GetPEM() and PemStatus() apparently won't be supported in X#.VFP.
That's a bummer... And I think it will cause pain to many people. I get that these Functions are definitely from a Dynamic Language perspective, and perhaps hard to wedge into a purely Object Oriented language platform.
However, as far as the GetPEM() function is concerned, that function is written in C# already in the Visual-FoxPro-Toolkit-for-.NET library.
/// Returns a bool specifying whether a property/method/event exists in an object.
/// (Currently this method does not implement all the parameters.)
/// <param name="oObject"></param>
/// <param name="cPropertyEventMethodName"></param>
/// //Create a new listbox
/// ListBox lstMyListBox;
/// lstMyListBox = new ListBox();
/// //Check if the listbox has a ForeColor or MyColor property
/// VFPToolkit.common.GetPem(lstMyListBox,"ForeColor"); //return true
/// VFPToolkit.common.GetPem(lstMyListBox,"MyColor"); //return false
public static bool GetPem(object oObject, string cPropertyEventMethodName)
//Get a list of all the properties in this object
PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(oObject);
//Beta 1 code
//PropertyDescriptor pda = TypeDescriptor.GetProperties(oObject).All;
//Loop through the properties an check if our property exists
foreach (MemberDescriptor md in pdc)
if (md.Name.ToLower() == cPropertyEventMethodName.ToLower())
//This means that we found our property
//Now we check for event name in this object
//Get a list of all the events/methods in this object
EventDescriptorCollection edc= TypeDescriptor.GetEvents(oObject);
//Loop through the events/methods an check if our event/method exists
foreach (EventDescriptor ed in edc)
if (ed.Name.ToLower() == cPropertyEventMethodName.ToLower())
//This means that we found our event/method
//If we reached here this means that we did not find our event/method/property
robert wrote: Matt,
It should not be a problem to support this. All the info about properties, fields and methods is available at runtime through reflection.
Can you show us how you are using these functions?
Often to get a reference when doing dynamic cofiguration, as property name is read as a string from file or table.
Cleaner and faster than calling eval() with host object "stringified" as well.