/// <summary> /// Adds an event listener configuration /// </summary> /// <param name="config">the configuration to add</param> /// <returns>the added configuration</returns> /// <exception cref="ArgumentNullException">When the configuration is null</exception> /// <exception cref="ArgumentException">When the configuration is already present.</exception> public EventListenerConfig Add(EventListenerConfig config) { if (config == null) { throw new ArgumentNullException("config"); } if (listeners.ContainsKey(config.ListenerType)) { throw new ArgumentException(string.Format("Configuration for Listener Type {0} is already present.", config.ListenerType.FullName), "config"); } var events = GetEventTypes(config.ListenerType); if (events.Length == 0) { throw new ArgumentException(string.Format("The Listener of type {0} does not implement any known NHibernate event listener interfaces.", config.ListenerType.FullName), "config"); } listeners.Add(config.ListenerType, config); foreach (var eventType in events) { if (!listenersPerEvent.ContainsKey(eventType)) { listenersPerEvent.Add(eventType, new HashedSet <Type>()); } listenersPerEvent[eventType].Add(config.ListenerType); } return(config); }
/// <summary> /// Adds an event listener configuration /// </summary> /// <param name="config">the configuration to add</param> /// <returns>the added configuration</returns> /// <exception cref="ArgumentNullException">When the configuration is null</exception> /// <exception cref="ArgumentException">When the configuration is already present.</exception> public EventListenerConfig Add(EventListenerConfig config) { if (config == null) throw new ArgumentNullException("config"); if (listeners.ContainsKey(config.ListenerType)) throw new ArgumentException(string.Format("Configuration for Listener Type {0} is already present.", config.ListenerType.FullName), "config"); var events = GetEventTypes(config.ListenerType); if (events.Length == 0) throw new ArgumentException(string.Format("The Listener of type {0} does not implement any known NHibernate event listener interfaces.", config.ListenerType.FullName), "config"); listeners.Add(config.ListenerType, config); foreach (var eventType in events) { if (!listenersPerEvent.ContainsKey(eventType)) listenersPerEvent.Add(eventType, new HashedSet<Type>()); listenersPerEvent[eventType].Add(config.ListenerType); } return config; }
private static object GetInstance(EventListenerConfig config) { return config.ListenerInstance ?? Activator.CreateInstance(config.ListenerType); }
private static object GetInstance(EventListenerConfig config) { return(config.ListenerInstance ?? Activator.CreateInstance(config.ListenerType)); }