n 계층 아키텍처에서 ASP.NET 프로필 시스템을 사용하려면 TableProfileProvider를 사용하고 있습니다.
UI 레이어는 웹 응용 프로그램이므로 프로필을 사용할 수 있으려면 profilecommon 클래스를 노출해야합니다.
다음은 내 아키텍처의 간단한 스키마입니다.
UI : ASP.NET 웹 응용 프로그램.
BusinessEntities : 순수 POCO 클래스. 지속성 Igronace.
BLL : 비즈니스 로직 계층.
DAL : 데이터 액세스 계층.n 계층 구조의 비즈니스 로직 계층에 System.Web 참조 추가
Profilecommon 정의는 다음과 같습니다
ProfileCommon strongleyTypedProfile = (ProfileCommon)이 다음과 같이
public class ProfileCommon : ProfileBase
{
public virtual ProfileCommon GetProfile(string username)
{
return (ProfileCommon)ProfileBase.Create(username);
}
public virtual string FirstName
{
get
{
return (string)base.GetPropertyValue("FirstName");
}
set
{
base.SetPropertyValue("FirstName", value);
}
}
}
, 내가 profilecommon에 액세스하는 것입니다. Context.Profile;
내 비즈니스 논리 레이어에서 프로필 일반에 액세스 할 수 있기를 바랬으므로 ProfileCommon 정의를 BusinessEntities 라이브러리 (BusinessEntities 라이브러리의 System.Web 어셈블리에 대한 참조를 추가해야 함)로 이동하고 새 ProfileBLL 등급 :
public class ProfileInfo
{
public ProfileInfo(ProfileCommon profile)
{
this.Profile = profile;
}
public ProfileCommon Profile { get; set; }
public string GetFullName()
{
return this.Profile.FirstName + " " + this.Profile.LastName;
}
}
지금 나는이 같은 UI에서 공통 프로파일에 액세스 할 수 있습니다
var profileInfo = new BLL.ProfileInfo((ProfileCommon)this.Context.Profile);
txtFullName.text = profileInfo.GetFullName();
를 이제 비즈니스 계층에 System.Web을 참조하는/BusinessEntities 도서관은 n 계층 아키텍처 분야를 위반? 그렇다면이 목표를 달성하기 위해 무엇을 제안 하시겠습니까?
@skaffman를 사용하여 웹 어플리케이션에서
IProfile
인터페이스를 구현하는 자유가없는 말할 수 있습니다 :이 n 계층 관련 질문이 아닙니다. 이것은 n-layer와 관련이 있습니다. n-tier는 하드웨어 수준에서 별도의 레이어가있는 경우를 의미합니다. – Kamyar