봉인 된 클래스의 내부 메서드에 액세스하려고하지만 봉인 된 클래스이므로 내부 메서드를 상속 할 수 없습니다. 내가 작업하고있는 솔루션의 백엔드 부분은 그런 식으로 설계되었습니다. 봉인 된 클래스의 내부 메서드에 액세스 C#
은 내가이 시도 클래스public static class LocalizationsManagerExtension
{
public static string AddAppUserBasic(this LocalizationsManager objDotnet, AppUser newUser, string pword)
{
try
{
objDotnet.AddAppUserBasic(newUser, pword);
return "Success!";
}
catch(Exception ex)
{
return ex.Message;
}
//return IdentityResult.Success;
//return System.Threading.Tasks.Task.Run();
//return "Welcome to the World of DotNet....Mr. " + password;
}
}
public ActionResult UserAddNew(UserAddNewModel model)
{
if (ModelState.IsValid)
{
var user = new DataAccess.AppUser();
user.Name = model.username;
user.Password = model.password;
user.DeveloperRole = model.isDeveloperRole;
user.AdministratorRole = model.isAdministratorRole;
user.TranslatorRole = model.isTranslatorRole;
user.IsDomainUser = model.IsDomainUser;
user.ManagerRole = model.isManagerRole;
user.State = Data.Framework.Repository.Helpers.ObjectState.Added;
var result = LM.AddAppUserBasic(user, user.Password);
if (result == "Success!")
{
ViewBag.ReturnUrl = "/Usermanagement/UserLogin";
//return RedirectToAction("UserLogin", "UserManagement");
}
else { }
}
// If we got this far, something failed, redisplay form
return View(model);
}
하지만 행운의 확장을 사용하는이에 대한 일을 주위 발견했다. "AddAppUserBasic"을 호출 할 수 있지만 호출하는 다른 메서드에서 로컬 메서드를 호출하고 있습니다. 봉인 된 학급에있는 학생이 아닙니다.
액세스 수정 자'internal'을 살펴보십시오. 어쩌면 수정 자에 대한 정보가 누락되었을 수 있습니다. [Here] (https://msdn.microsoft.com/en-us/library/7c5ka91b.aspx) –
은 왜 디자이너가 내부적으로 만들 것인지 결정한 디자이너에게 물어 봅니다. 팀원들과 자신을 동기화해야합니다 –
봉인 된 클래스에서 아무것도 상속받을 수 없으며 내부 메서드 만 남겨 두십시오. –