Suppose we have a class like :
public void Login(string serverName, string username, string password)
{
Server.ServerName = serverName;
Server.DatabaseName = db;
Server.Username = username;
Server.Password = password;
this.Initiate();
}
private void Initiate()
{
Server.IsAuthorized = true;
}
public Patient GetPatient(string admCode)
{
if (Server.IsAuthorized)
{
}
}
and internal static
class is something like:
internal static class Server
{
internal static string ServerName { get; set; }
internal static string DatabaseName { get; set; }
internal static bool IsAuthorized { get; set; }
public static string Username { get; set; }
public static string Password { get; set; }
}
When I want to execute methods by reflection the return value is empty for GetPatient
like:
Assembly assembly = Assembly.LoadFrom(path);
Type myType = assembly.GetType("myType");
MethodInfo loginMethod = myType.GetMethod("Login");
MethodInfo getPatient = myType.GetMethod("GetPatient");
object obj = Activator.CreateInstance(myType);
var login = loginMethod.Invoke(obj, new object[] { m_ServerAddress, _userName, _pass });
var objPatient = getPatient.Invoke(obj, new object[] { id });
Is this because of that internal static class?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire