Background:
- I have a win app and a web app and a shared class library.
- In my class lib I have some static methods for SQL queries which pick up my SQL connection string
- I store my SQL connection string in a Session variable since it is set at log in time where it is determined which database to use.
- My class lib cannot access my session variables (yes, of course I can use HttpContext.Current..., but that wont work in my winapp)
Solution?
I envision a sort of solution where I have a class for my current user/context and when creating it I inject the preferred behaviour, something like this:
UserContex current = new UserContext();
current.SessionHandler = new AspNetSessionHandler();
However, I would like a static class which I could user without having to pass it along all the time and then it would get it's variables either from the session if used in a web app or from somewhere else (I'm not a winapp developer) if used in a winform.
I will try to conjure up this kind of thing, but it would be great if I found an already working solution and that's why I call on the shared collective madness of you guys