Esempio n. 1
0
        internal Delegate GetEventLoggerDelegate(ObjectEvent objectEvent)
        {
            EventInfo eventInfo = objectEvent._eventInfo;
            Type      handlerType;
            Type      delegateType = eventInfo.EventHandlerType;

            objectEvent.SetEventParams();

            lock (this)
            {
                handlerType = (Type)_loggerTypeHash[eventInfo.EventHandlerType];
                if (handlerType == null)
                {
                    handlerType = CreateEventHandlerDelegate(eventInfo, objectEvent._eventParams,
                                                             objectEvent._eventReturnType);
                    _loggerTypeHash.Add(eventInfo.EventHandlerType, handlerType);
                }
            }

            // Create the setup the logger object
            EventLogger logger = (EventLogger)Activator.CreateInstance(handlerType);

            AddLoggerInstance(objectEvent, logger);
            logger._eventLog    = this;
            logger._objectEvent = objectEvent;

            Delegate d = Delegate.CreateDelegate(delegateType, logger, "Logger");

            TraceUtil.WriteLineInfo(this, "Found delegate: " + delegateType);
            return(d);
        }
Esempio n. 2
0
		internal Delegate GetEventLoggerDelegate(ObjectEvent objectEvent)
		{
			EventInfo eventInfo = objectEvent._eventInfo;
			Type handlerType;
			Type delegateType = eventInfo.EventHandlerType;

			objectEvent.SetEventParams();

			lock (this)
			{
				handlerType = (Type)_loggerTypeHash[eventInfo.EventHandlerType];
				if (handlerType == null)
				{
					handlerType = CreateEventHandlerDelegate(eventInfo, objectEvent._eventParams,
						 objectEvent._eventReturnType);
					_loggerTypeHash.Add(eventInfo.EventHandlerType, handlerType);
				}
			}

			// Create the setup the logger object
			EventLogger logger = (EventLogger)Activator.CreateInstance(handlerType);
			AddLoggerInstance(objectEvent, logger);
			logger._eventLog = this;
			logger._objectEvent = objectEvent;

			Delegate d = Delegate.CreateDelegate(delegateType, logger, "Logger");
			TraceUtil.WriteLineInfo(this, "Found delegate: " + delegateType);
			return d;
		}