Esempio n. 1
0
        /// <summary>
        /// Removes command from property change listener
        /// </summary>
        /// <param name="cmd">Cmd.</param>
        public void RemovePropertyChangeListener(IAtomCommandBase cmd)
        {
            if (cmd == null)
            {
                throw new ArgumentNullException(nameof(cmd));
            }

            var cmdHashCode = cmd.GetHashCode();

            foreach (var curr in Commands)
            {
                if (curr.GetHashCode() == cmdHashCode)
                {
                    Commands.Remove(cmd);

                    break;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Registers a command to listen to any property change
        /// </summary>
        /// <param name="cmd">Cmd.</param>
        public void AddPropertyChangeListener(IAtomCommandBase cmd)
        {
            // validate the argument
            if (cmd == null)
            {
                throw new ArgumentNullException(nameof(cmd));
            }

            // make sure that it is added only once
            var cmdHashCode = cmd.GetHashCode();

            foreach (var curr in Commands)
            {
                if (curr.GetHashCode() == cmdHashCode)
                {
                    return;
                }
            }

            // if it does not exist, add the command
            Commands.Add(cmd);
        }