ShaneKm
ShaneKm

Reputation: 21338

How to create a wrapper class that uses session

What is the proper way to create a wrapper class for 3rd party library:

I've created a wrapper like so:

public class UserContextWrapper
{
     // 3rd party lib
     private UserContext _userContext;

     public string City {
          get { return _userContext.City; }
     }

     public Organization Organization {
          get { return _userContext.Organization; }
     }

     // Create properties that wrap UserContext 3rd party lib properties
}
  1. Is this the proper way to create wrappers?
  2. I need to use (3rd party lib) Organization property which I can not mock because it uses session in it's constructor:

public class Organization() { // fill in session info };

Upvotes: 0

Views: 181

Answers (1)

ShaneKm
ShaneKm

Reputation: 21338

This helped Create only those functions that has value with your code and little by little if you need another functions add it up in your wrapper.

Upvotes: 0

Related Questions