コード例 #1
0
        internal string RaiseOnPromptEvent(string Message)
        {
            if (_loginPassword != null && Message == "Enter password: ")
            {
                //no need to raise an event...
                return(_loginPassword);
            }


            // Make a temporary copy of the event to avoid possibility of
            // a race condition if the last subscriber unsubscribes
            // immediately after the null check and before the event is raised.
            OnPromptEventHandler handler = OnPrompt;

            // Event will be null if there are no subscribers
            if (handler != null)
            {
                P4PromptEventArgs e = new P4PromptEventArgs(Message);

                // Use the () operator to raise the event.
                handler(this, e);
                return(e.Response);
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #2
0
ファイル: P4Connection.cs プロジェクト: orecht/P4.net
        // Wrap event invocations inside a protected virtual method
        // to allow derived classes to override the event invocation behavior
        private string RaiseOnPromptEvent(string Message)
        {
            // Make a temporary copy of the event to avoid possibility of
            // a race condition if the last subscriber unsubscribes
            // immediately after the null check and before the event is raised.
            OnPromptEventHandler handler = OnPrompt;

            // Event will be null if there are no subscribers
            if (handler != null)
            {
                P4PromptEventArgs e = new P4PromptEventArgs(Message);
                
                // Use the () operator to raise the event.
                handler(this, e);
                return e.Response; 
            }
            else
            {
                return string.Empty;
            }
        }
コード例 #3
0
 private void HandleOnPrompt(object sender, P4PromptEventArgs e)
 {
     e.Response = RaiseOnPromptEvent(e.Message);
 }
コード例 #4
0
ファイル: P4Connection.cs プロジェクト: orecht/P4.net
 private void HandleOnPrompt(object sender, P4PromptEventArgs e)
 {
     e.Response = RaiseOnPromptEvent(e.Message);
 }