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.
.
Code: Select all
GetPem(object oObject, string cPropertyEventMethodName)
Code: Select all
/// <summary>
/// Returns a bool specifying whether a property/method/event exists in an object.
/// (Currently this method does not implement all the parameters.)
/// </summary>
/// <param name="oObject"></param>
/// <param name="cPropertyEventMethodName"></param>
/// <returns></returns>
///
/// //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
return true;
}
}
//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
return true;
}
}
//If we reached here this means that we did not find our event/method/property
return false;
}