反射机制的初次应用

看了一下反射机制,觉得就是动态的DLL装载嘛   
Assembly LoginFile = Assembly.LoadFile(page.Request.PhysicalApplicationPath + ConfigurationSettings.AppSettings["LoginPath"]);
   Type LoginDll = LoginFile.GetType(ConfigurationSettings.AppSettings["LoginClass"]);
   MethodInfo LoginMethod = LoginDll.GetMethod("DoLogin");
   String[] LoginParameter = {UserName,Password};
   Object LoginObj = Activator.CreateInstance(LoginDll);
   UserObject NowUser = (UserObject)LoginMethod.Invoke(LoginObj,LoginParameter);
   if (NowUser != null)
   {
    Hashtable Privileges = LoadPrivilege(NowUser,page);
    UserInfo nowUser = new UserInfo(NowUser.Name,NowUser.Password,Convert.ToBoolean(NowUser.AdminFlag),NowUser.IP,NowUser.ID,Privileges);
    page.Session["User"] = nowUser;
    return true;
   }
   else{
    return false;
   }
posted @ 2004-10-21 15:37  Enli  阅读(685)  评论(2编辑  收藏  举报