M
Mirek Endys
Hello all,
another problem im solving right now. I badly need to get typeof object that
called static method in base classe. I did it by parameter in method Load,
but i thing there should be way, how to get this information in called
method.
Thanks.
public abstract class BaseClass
{
public static BaseClass Load(SqlConnection sConnection)
{
// ****************************************
// here is code for loading data from SqlDB
// ****************************************
// look at ???callingObjectType???
BaseClass newItem =
(BaseUDCObject)System.Activator.CreateInstance(???callingObjectType???, new
string[] { Convert.ToString(dataReader["ID"]),
Convert.ToString(dataReader["Description"]) });
return newItem;
}
}
public class MyClass : BaseClass
{
private string _ID = null;
private string _Description = null;
public MyClass(string id, string description)
{
this._ID = id;
this._Description = description;
}
public static MyClass Load(SqlConnection sqlConn)
{
return (MyClass)BaseClass.Load(sqlConn)
}
}
another problem im solving right now. I badly need to get typeof object that
called static method in base classe. I did it by parameter in method Load,
but i thing there should be way, how to get this information in called
method.
Thanks.
public abstract class BaseClass
{
public static BaseClass Load(SqlConnection sConnection)
{
// ****************************************
// here is code for loading data from SqlDB
// ****************************************
// look at ???callingObjectType???
BaseClass newItem =
(BaseUDCObject)System.Activator.CreateInstance(???callingObjectType???, new
string[] { Convert.ToString(dataReader["ID"]),
Convert.ToString(dataReader["Description"]) });
return newItem;
}
}
public class MyClass : BaseClass
{
private string _ID = null;
private string _Description = null;
public MyClass(string id, string description)
{
this._ID = id;
this._Description = description;
}
public static MyClass Load(SqlConnection sqlConn)
{
return (MyClass)BaseClass.Load(sqlConn)
}
}