/// <summary>
        /// Raises this <see cref="HostAdded"/> event.
        /// </summary>
        /// <param name="e">The event data.</param>
        private void OnHostAdded(HostAddedEventArgs e)
        {
            EventHandler <HostAddedEventArgs> handler = this.HostAdded;

            if (handler != null)
            {
                handler(this, e);
            }
        }
示例#2
0
        /// <summary>
        /// Occurs when a new host has been added to the known host collection.
        /// </summary>
        /// <param name="sender">The object where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void KnownHostSet_HostAdded(object sender, HostAddedEventArgs e)
        {
            // Determine if the new host is one of the identity words. But only if the
            // host is not the first or last word which has to be name and display.
            string knownHost = this.identityWords.Where((w, index) =>
                                                        w == e.Host && index != 0 && index != this.identityWords.Length - 1).FirstOrDefault();

            if (!string.IsNullOrEmpty(knownHost))
            {
                // If the host is known then we do not need to listen for new hosts.
                //// If this is the first time the user was parsed then this will do nothing.
                //// This will have an effect only when this is the second pass and a new host
                //// was reported that is in the words.
                KnownHostSet.Instance.HostAdded -= this.KnownHostSet_HostAdded;

                // This pattern is repeated in DetermineIdentityPattern.
                this.ParseIdentity(string.Format(@"(?<name>.+) (?<host>{0}) (?<display>.+)", knownHost));
            }
        }