Ejemplo n.º 1
0
        /// <summary>
        /// Removes first occurence of given 'method' from listener list for specified 'identifier'.
        /// </summary>
        /// <param name="identifier">Identifier of the custom event that will be forgotten to.</param>
        /// <param name="method">Method that will be called if specified custom event occurs.</param>
        /// <returns>Number of the methods listening specified custom event!</returns>
        public int ForgetCustomEvent(string identifier, CustomEventOccuredDelegate method)
        {
            if (!CustomEventListeners.ContainsKey(identifier))
            {
                return((int)ScriptError.CustomEventNotRegisteredYet);
            }

            CustomEventListeners[identifier].Remove(method);
            return(CustomEventListeners[identifier].Count);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds given 'method' to listener list for specified 'identifier'.
        /// </summary>
        /// <param name="identifier">Identifier of the custom event that will be listened to.</param>
        /// <param name="method">Method that will be called if specified custom event occurs.</param>
        /// <returns>Number of the methods listening specified custom event!</returns>
        public int ListenCustomEvent(string identifier, CustomEventOccuredDelegate method)
        {
            if (!CustomEventListeners.ContainsKey(identifier))
            {
                CustomEventListeners.Add(identifier, new List <CustomEventOccuredDelegate>());
            }

            CustomEventListeners[identifier].Add(method);
            return(CustomEventListeners[identifier].Count);
        }