none
how to create wrapper for Enterprise library Data block as seprarate component RRS feed

  • Question

  • Hi,

     

    I have the following scenario.

    The project has 4 layers

    1) Business Entities

    2)Business Layer

    3)DataLayer

    all are separate projects
    so lets say

    1 )Business Entities has
     

    public class Employee
    {
    public int EmpId{get;set;}
    public string EmpName{get;set}
    pullic int Age{get;set;}
    }

    2)Business layer will call dataacess layer

    public class BusinessLayer
    {

    public int RegisterEmployee(Employee objEmp)
    {
     Datalayer objDal =new Datalayer();
     objDal.AddEmployee(objEmp)

    }
    }


    3)From the datalayer i need to call Wrapper for enterprise library and the requirement is
    datalayer should not have any reference of Enterprise library data block(that i dont know how to do that)
    Only the wrapper class should have reference for Enterprise library data block

    so

    public class Datalayer
    {
     public int AddEmployee(Employee objEmp)
    {
    ///Database db=DatabaseFactor.Createdatabase()
    //the above line should not be in datalayer it should in some other componenent
    //lets say component is wrapper
    //i want to how to write wrapper for that.
    //As well as how to build command and parameter

    //As well as the wrapper should not take business object ie the Employee object as parameter either it should take command or paramters
    }
    }

    Any suggestion on developing such wrapper component


    ilikemicrosoft
    Wednesday, November 24, 2010 8:08 PM

All replies

  • Hello there,

    Some links are given below.

    Wrapper Patterns in C#, Part IV: The Adapter Pattern
    http://www.c-sharpcorner.com/UploadFile/rmcochran/csharp_wrapper402122006091959AM/csharp_wrapper4.aspx

    Adapter
    http://www.dofactory.com/Patterns/PatternAdapter.aspx

    Hope this helps,

    Regards,

    Phijo Mathew Philip.


    PHIJO MP
    Thursday, November 25, 2010 10:39 AM
  • In computer programming, the adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface. An adapter allows classes to work together that normally could not because of incompatible interfaces, by providing its interface to clients while using the original interface. The adapter translates calls to its interface into calls to the original interface, and the amount of code necessary to do this is typically small. The adapter is also responsible for transforming data into appropriate forms. For instance, if multiple boolean values are stored as a single integer but your consumer requires a 'true'/'false', the adapter would be responsible for extracting the appropriate values from the integer value.

     Object Adapter pattern

     In this type of adapter pattern, the adapter contains an instance of the class it wraps. In this situation, the adapter makes calls to the instance of the wrapped object.

     Class Adapter pattern

     This type of adapter uses multiple inheritance to achieve its goal. The adapter is created inheriting from both the interface that is expected and the interface that is pre-existing. It is typical for the expected interface to be created as a pure interface class, especially in languages such as Java that do not support multiple inheritance.


    PHIJO MP
    Thursday, November 25, 2010 10:44 AM