Im writing a custom ORM. For that reason create a mapping property, which tells me that property of object1 is mached with the property of object 2.
the method CallPropertyMethod (Object pclass) resive as parameter an object, which according to its name, serves to search in the dictionary the corresponding delegate, which is going to run the method that corresponds to him, that can be in this case PropertyMachEmployee or PropertyMachCompany.
But I have a error in the line pdelegate(), I dont know if this is posible, and if is posible How I can do it.???
public class MapProperty
{
public static Dictionary<string, string> DicMapProperty;
public static Dictionary<string, Delegate> DicClassName;
public delegate void DelCompany();
public MapProperty() {
DelCompany odelCompany = new DelCompany(PropertyMachCompany);
DelCompany odelEmployee = new DelCompany(PropertyMachEmployee);
DicClassName = new Dictionary<string, Delegate>();
DicClassName.Add("Company", odelCompany);
DicClassName.Add("Employee", odelEmployee);
}
public void CallPropertyMethod (Object pclass)
{
string className = pclass.GetType().Name;
var pdelegate = DicClassName[className];
pdelegate();
}
public void PropertyMachCompany() {
DicMapProperty = new Dictionary<string, string>();
DicMapProperty.Add("id","Id");
DicMapProperty.Add("companyName", "Company_Name");
}
public void PropertyMachEmployee()
{
DicMapProperty = new Dictionary<string, string>();
DicMapProperty.Add("id", "Id");
DicMapProperty.Add("name", "Name");
DicMapProperty.Add("name", "Name");
}
}
Aucun commentaire:
Enregistrer un commentaire