I have a custom TraceListener that inherits from FormattedTraceListenerBase and I would like to get access to values that are only available to me at runtime. (username and password) The listener uses reflection to create an instance of a web service
client proxy and execute a method to send log information back to the server and into the database. If I have no security on the web service it works like a champ. I even have it fully integrated with the configuration tool. Very nice.
In my override of the Write method I'd like to get the username and password. I am using Prism and can put things in the container but I can't find a way to get Entlib to use that container so I can retrive things at runtime.
I have tried this in the ConfigureContainer override in my bootstrapper:
GlobalSettings settings = new GlobalSettings();
settings.LogonInfo.UserName = "blah";
settings.LogonInfo.Password = "blahblah";
IServiceLocator locator = new UnityServiceLocator(Container);
EnterpriseLibraryContainer.Current = locator;
This appeared to work but now I've figured out that even if I don't register an instance in the bootstrapper, I still get one in the Write method with:
Is there a way to get the EnterpriseLibrary to use the container that is already in my application? Is this perhaps the wrong approach to pass runtime information to the listener?
I am already creating a GenericPrincipal for use in my application. I could extend that or the GenericIdentity and then just get the information from:
I know that that will work but it made me feel dirty. :)
Thanks for any pointers you can offer.