.net - Adding System.Web reference to Business Logic Layer in n-layer Architecture -


i'm using tableprofileprovider use asp.net profile system in n-layer architecture.
ui layer web application have expose profilecommon class able use profiles.
here's simplified schema of architecture:
ui: asp.net web application.
businessentities: pure poco classes. persistence igronace.
bll: business logic layer.
dal: data access layer.

the profilecommon definition is:

 public class profilecommon : profilebase  {     public virtual profilecommon getprofile(string username)     {         return (profilecommon)profilebase.create(username);     }      public virtual string firstname     {                 {             return (string)base.getpropertyvalue("firstname");         }         set         {             base.setpropertyvalue("firstname", value);         }     }  }   

in simple design architecture defined in web application project, i'd access profilecommon follows:
profilecommon strongleytypedprofile = (profilecommon)this.context.profile;

i'd able access profile common business logic layer, moved profilecommon definition businessentities library (had add reference system.web assembly in businessentities library) , defined new profilebll class:

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;     } }   

now can access profile common ui this:

var profileinfo = new bll.profileinfo((profilecommon)this.context.profile); txtfullname.text = profileinfo.getfullname(); 

now, referencing system.web in business layer/businessentities library violates n-layer architecture disciplines? if so, suggest in order achieve this?

you can break dependency on profilebase implementing interface instead. lets say

public interface iprofile {     string firstname { get; set; }     string lastname { get; set; }      iprofile getprofile(string username); }  public class profilecommon : profilebase, iprofile  {     public virtual iprofile getprofile(string username)     {         return (profilecommon)profilebase.create(username);     }      public virtual string firstname     {                 {             return (string)base.getpropertyvalue("firstname");         }         set         {             base.setpropertyvalue("firstname", value);         }     }  }  public class profileinfo {     public profileinfo(iprofile profile)     {         this.profile = profile;     }      public iprofile profile { get; set; }      public string getfullname()     {         return this.profile.firstname + " " + this.profile.lastname;     } }  

now don't have dependency on system.web.dll in business logic still have freedom implement iprofile interface in webapplication using profilebase


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -