Пример #1
0
 public void AddPmSubscription(EventHandler<LogsMonitorEventArgs> eventHandler, string pmRecipient)
 {
     var key = new PmSubscriptionKey(eventHandler, pmRecipient);
     bool success = pmSubscriptions.TryAdd(
         key,
         new EnginePmSubscription()
         {
             PmRecipientNormalized = pmRecipient.ToUpperInvariant(),
             LogsMonitorPmEventHandler = eventHandler
         });
     if (!success)
     {
         logger.Log(LogLevel.Warn,
             string.Format(
                 "Attempted to AddPmSubscription with handler, that's already subscribed. "
                 + "Additional subscription will be ignored. "
                 + "PmRecipient: {0} Handler pointing to method: {1}", pmRecipient,
                 eventHandler.MethodInformationToString()), this, null);
     }
 }
Пример #2
0
 public void RemovePmSubscription(EventHandler<LogsMonitorEventArgs> eventHandler, string pmRecipient)
 {
     var key = new PmSubscriptionKey(eventHandler, pmRecipient);
     EnginePmSubscription manager;
     if (pmSubscriptions.TryGetValue(key, out manager))
     {
         manager.LogsMonitorPmEventHandler = null;
         pmSubscriptions.TryRemove(key, out manager);
     }
 }