Table of contents
- 1 Defining the Interface
- 2 Creating the wrapper
DictionaryAdapter Basics
The DictionaryAdapter workd by examining an interface, and then generating an object with getters and setters around the given dictionary, based on the interface's properties
Defining the Interface
Assuming we want to be able to access a session variable named "UserId". Let's create an Interface for that.
public interface IUserIdAware { int UserId { get; set; } }
Creating the wrapper
Now in your code you can use that:
...
IUserIdAware TypedSession = new DictionaryAdapterFactory().GetAdapter<IUserIdAware>(Session);
TypedSession.UserId = 5;
...