private void RecordEventSource(ICommonLoggingEventSource candidate)
{
//if we have a valid object
if (candidate != null)
{
var eventSourceType = candidate.GetType();
//if we don't already have an instance of this same type in the registry...
if (!EventSourceRegistry.ContainsKey(eventSourceType))
{
//...add it
EventSourceRegistry.Add(eventSourceType, candidate);
}
else
{
//if the incoming instance is _not_ the same instance as that already registered...
if (EventSourceRegistry[eventSourceType] != candidate)
{
//...react accordingly to the attempted duplicate registration
ThrowIfDuplicateEventSourceTypeRegistrationNotPermitted(eventSourceType);
}
//if we get this far, replace the existing instance with the new instance
EventSourceRegistry[eventSourceType] = candidate;
}
//set the type designator so we can keep track of the correct EventSource Type for this adapter
_eventSourceType = eventSourceType;
}
}