Пример #1
0
        public virtual void WriteRemoveListener(RemoveListener s, ExpressionUsage u)
        {
            Begin(u);

            if (s.Object == null)
            {
                WriteStaticType(s.Source, s.Event.DeclaringType);
            }
            else
            {
                WriteExpression(s.Object, ExpressionUsage.Object);
            }

            Write("." + s.Event.Name + " -= ");
            WriteExpression(s.Listener);
            End(u);
        }
Пример #2
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Name.Expression != null)
            {
                targetCommand.AddParameter("Name", Name.Get(context));
            }

            if (Option.Expression != null)
            {
                targetCommand.AddParameter("Option", Option.Get(context));
            }

            if (ListenerOption.Expression != null)
            {
                targetCommand.AddParameter("ListenerOption", ListenerOption.Get(context));
            }

            if (FilePath.Expression != null)
            {
                targetCommand.AddParameter("FilePath", FilePath.Get(context));
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (Debugger.Expression != null)
            {
                targetCommand.AddParameter("Debugger", Debugger.Get(context));
            }

            if (PSHost.Expression != null)
            {
                targetCommand.AddParameter("PSHost", PSHost.Get(context));
            }

            if (RemoveListener.Expression != null)
            {
                targetCommand.AddParameter("RemoveListener", RemoveListener.Get(context));
            }

            if (RemoveFileListener.Expression != null)
            {
                targetCommand.AddParameter("RemoveFileListener", RemoveFileListener.Get(context));
            }

            if (PassThru.Expression != null)
            {
                targetCommand.AddParameter("PassThru", PassThru.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Пример #3
0
 public void RemoveRemoveListener(RemoveListener listener)
 {
     removeListeners.Remove(listener);
 }
Пример #4
0
 public int OnRemove(RemoveListener listener)
 {
     return(Utilities.Add(removeListeners, listener));
 }